Skip to content

Instantly share code, notes, and snippets.

@magemore
magemore / example.js
Created August 10, 2016 10:13
upload image from clipboard on ctrl+v event on page
function uploadFile(file) {
var formData = new FormData();
formData.append("userfile", file);
var request = new XMLHttpRequest();
request.onload = function () {
if (request.status == 200) {
document.location.href='/';
} else {
alert('Error! Upload failed');
}
@magemore
magemore / crawler.go
Last active September 12, 2023 13:20
simple domains crawler go lang million in 24h from cheap laptop on 10Mb/s connection
package main
import (
"fmt"
"net"
"net/http"
"io/ioutil"
"os"
"bufio"
"log"
@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 / gist:4499587
Created January 10, 2013 04:56
Amazon Linux AMI (Fedora) install htop
# update
sudo yum -y update
sudo yum -y upgrade
# enable EPEL6 by changing enabled=0 -> enabled=1
sudo vim /etc/yum.repos.d/epel.repo
# install htop
sudo yum install htop
@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));
}