Skip to content

Instantly share code, notes, and snippets.

@magemore
magemore / curl.php
Created May 3, 2023 13:50
curl fix
$chD = curl_init();
curl_setopt_array($chD, array(
CURLOPT_URL => $ReportDocArray['url'],
CURLOPT_HEADER => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_BINARYTRANSFER => true, // Set to true for binary files
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
@magemore
magemore / canvas_draw.js
Created March 24, 2023 15:56
Canvas draw image from one to other
const canvas1 = document.getElementById("canvas1");
const ctx1 = canvas1.getContext("2d");
const canvas2 = document.createElement("canvas");
canvas2.width = canvas1.width;
canvas2.height = canvas1.height;
const ctx2 = canvas2.getContext("2d");
const img = new Image();
img.onload = function() {
@magemore
magemore / top_1000_usa_cities_by_population.csv
Last active February 28, 2023 20:29
Top 1000 USA Cities by population with zip codes
1 New York New York 8405837 4.8%
2 Los Angeles California 3884307 4.8%
3 Chicago Illinois 2718782 -6.1%
4 Houston Texas 2195914 11.0%
5 Philadelphia Pennsylvania 1553165 2.6%
6 Phoenix Arizona 1513367 14.0%
7 San Antonio Texas 1409019 21.0%
8 San Diego California 1355896 10.5%
9 Dallas Texas 1257676 5.6%
10 San Jose California 998537 10.5%
@magemore
magemore / questions_about_cryptogpt+for_chatgpt.txt
Last active February 20, 2023 16:00
What is CryptoGPT and how it could work?
Describe Zero-knowledge rollups (ZK-rollups) are layer 2
Zero-knowledge rollups (ZK-rollups) are a type of Layer 2 scaling solution for blockchains that aim to increase transaction throughput while maintaining the security and decentralization features of the underlying blockchain.
In a ZK-rollup, multiple transactions are aggregated and processed off-chain, and the resulting state changes are then committed to the blockchain as a single transaction. This allows for much higher transaction throughput and lower fees, as well as faster confirmation times.
ZK-rollups use zero-knowledge proofs (ZKPs) to ensure the integrity of the transaction data without revealing any sensitive information. This means that users can submit transactions to the ZK-rollup with complete privacy, while the network can still verify the validity of the transactions without needing to access the individual transaction data.
ZK-rollups are considered to be more secure and decentralized than other Layer 2 solutions, such as sidechains,
//Using Axios
const axios = require('axios');
axios.get('https://pro-api.coinmarketcap.com/v1/tools/price-conversion?amount=1&symbol=MAIN&convert=USD', {
headers: {
'X-CMC_PRO_API_KEY': CMC_PRO_API_KEY,
},
})
.then(function (response) {
// get BNB price in BUSD
#!/usr/bin/python
import struct
import time
import sys
infile_path = "/dev/input/event6"
#long int, long int, unsigned short, unsigned short, unsigned int
FORMAT = 'llHHI'
EVENT_SIZE = struct.calcsize(FORMAT)
@magemore
magemore / test.html
Created January 15, 2019 19:30
javascript parse text table. upload file. associative array. filter array
<html>
<head>
<meta charset="UTF-8">
<script>
function isEven(n) {
n = Number(n);
return n === 0 || !!(n && !(n % 2));
}
@magemore
magemore / google_geo_location.html
Last active January 3, 2019 18:53
google_geo_location.js
<script>
var map = false;
var markers = [];
var infoWindow;
var locationSelect;
function initMap() {
if (typeof google === 'undefined' || google === null) {
setTimeout(initMap, 300);
return;
xlsxj = require('xlsx-to-json');
xlsxj({
input: 'p.xlsx',
output: 'php-books.json'
}, function(err, result) {
if (err) {
console.log(err);
}
else {
console.log(result);
run = require('./run-php.js')
run [
'$ci->load->library(\'shop_catalog\')'
'$r=$ids=explode(\',\',$ci->shop_catalog->getRefineFromTopMenuCategory(1))'
], (data) ->
console.log data