Skip to content

Instantly share code, notes, and snippets.

View meeDamian's full-sized avatar
👨‍💻
Lightning Networking

Damian Mee meeDamian

👨‍💻
Lightning Networking
View GitHub Profile
@meeDamian
meeDamian / progranizm-2.5.1.c
Created September 18, 2011 16:48
[ C | pure_awesome ] Realisation of genetic algorythm
// Progranism Source Code: Version 2.5.1
// This new version of Progranisms should handle restrictive environments better
// It implements a better method of seeding the random number generator
// Returning to asexual behavior
// 2.5.1: Modified mutation selection code
// This is Linux code and should not compile under Windows
#include <sys/time.h>
#include <stdio.h>
@meeDamian
meeDamian / Math.toString(64).js
Created June 10, 2013 14:32
Convert number to it's base-64 representation, and reverse it. It is NOT THE SAME as Base64 encoding!
var Base64 = function(){};
Base64._rixits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_";
Base64.toHash = function( n ) {
if( isNaN(Number(n)) || n===null || n===Number.POSITIVE_INFINITY || n<0 ) throw "The input is not valid";
n = Math.floor( n );
var result = '';
do result = this._rixits.charAt(n%64) + result;
while( n=Math.floor(n/64) );
return result; // String
@meeDamian
meeDamian / negative_mod.js
Created April 24, 2012 08:01
[ JS | fix ] Negative Modulo Fix
/*
* By default JS returns invalid modulo values for negative numbers,
* below line fixes this, by overriding default js mod function
*/
Number.prototype.mod=function(n){return((this%n)+n)%n;}
$ cat Dockerfile
FROM alpine:3.12
RUN { uname -a; uname -m; printf '\n\n'; cat /proc/cpuinfo; } > /root/me.txt
ENTRYPOINT [ "cat", "/root/me.txt" ]
$ TAG='meedamian/docker-ci:v12.7.2020'
$ docker manifest inspect alpine:3.12 | jq -r '.manifests[].platform | .os + "/" + .architecture + " " + .variant'
linux/amd64
linux/arm v6
package main
import (
"fmt"
"io/ioutil"
"os"
"regexp"
"strings"
"github.com/BurntSushi/toml"
BEGIN MESSAGE.
Sw1PBSKPuyTysVy gZXX1djGS17VP8k rHn7IxbTeJXZ9bt GZue2SmxtdUA7ej
A5Ddm1b72VkW7xr vM7rUfUuR6jTCKq 6Xr2MZHgg6oNuC9 nkEQRsGdOelo3e7
wRco5AgmmO2bs9K UT6hXr1eTb0Ecgt Wi53jycGZpxTg1q GKipgamPtWo1hYQ
8Qmq35ePuyF3qa3 tZsuYtm6PdCmtJK hmCHg29HFxl.
END MESSAGE.
'use strict';
const RESET_AFTER_HOURS = 6;
const HOUR = 36e5; // 60 * 60 * 1000;
class Tabs {
constructor() {
this.restore()
}
@meeDamian
meeDamian / shorten.php
Created December 20, 2011 08:39
[ PHP | api | google ] goo.gl link shortenter
<?
// add it to config file:
$google_key = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
// add this to libs file:
function shorten($url) {
$gurl = "https://www.googleapis.com/urlshortener/v1/url?key=" . $GLOBALS['google_key'];
$url = json_encode(array("longUrl" => $url));
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
@meeDamian
meeDamian / blocks-per-day.sh
Created March 20, 2020 15:22
Get amount of BTC block per sel-reported date.
#!/bin/sh
LAST_DATE="$1"
last="$(bitcoin-cli getblockcount)"
get_last() {
while true; do
DATE="$(date -d "@$(bitcoin-cli getblock "$(bitcoin-cli getblockhash "$last")" | jq '.time')" +"%Y-%m-%d")"
package main
import (
"context"
"encoding/hex"
"fmt"
"io/ioutil"
"time"
"github.com/lncm/lnd-rpc/v0.9.0/lnrpc"