Skip to content

Instantly share code, notes, and snippets.

# begin build properties
# autogenerated by buildinfo.sh
ro.build.id=JSS15J
ro.build.display.id=JSS15J.I9505XXUEML1
ro.build.version.incremental=I9505XXUEML1
ro.build.version.sdk=18
ro.build.version.codename=REL
ro.build.version.release=4.3
ro.build.date=Tue Dec 10 14:28:08 KST 2013
ro.build.date.utc=1386653288
# Reference:
# http://blog.onyxbits.de/how-to-get-the-google-play-user-agent-for-a-given-device-140/
#
# Run script on a jailbroken Android device via terminal to get the User-Agent information. Use the following steps:
# $ adb push executable /data/local/tmp
# $ adb shell
# $ cd /data/local/tmp
# $ chmod 755 executable
# $ ./get_user_agent_details.sh
@alexcmd
alexcmd / gist:837f8069cb86c6bb6fccb291bc5172b2
Created January 31, 2017 06:55 — forked from lucasferreira/gist:1135780
Get image data in Javascript
//from: http://stackoverflow.com/questions/934012/get-image-data-in-javascript
function getBase64Image(img) {
// Create an empty canvas element
var canvas = document.createElement("canvas");
canvas.width = img.width;
canvas.height = img.height;
// Copy the image contents to the canvas
var ctx = canvas.getContext("2d");
function getBase64FromImageUrl(url) {
var img = new Image();
img.setAttribute('crossOrigin', 'anonymous');
img.onload = function () {
var canvas = document.createElement("canvas");
canvas.width =this.width;
canvas.height =this.height;
@alexcmd
alexcmd / FloatPointNumberToFraction.cs
Created March 23, 2017 15:50
Converter floating point number to Fraction representation
class Program
{
static void Main(string[] args)
{
double num = 0.3333;
double denom = 1.0 / (Eps * 10.0);
num = (int)(num * denom);
double gcd = (double)find_gcd((int)num, (int)denom);
num /= gcd;

View installed PPA Repository with a .sh script

#! /bin/sh 
# listppa Script to get all the PPA installed on a system ready to share for reininstall
for APT in `find /etc/apt/ -name \*.list`; do
    grep -o "^deb http://ppa.launchpad.net/[a-z0-9\-]\+/[a-z0-9\-]\+" $APT | while read ENTRY ; do
        USER=`echo $ENTRY | cut -d/ -f4`
        PPA=`echo $ENTRY | cut -d/ -f5`
 echo sudo apt-add-repository ppa:$USER/$PPA
@alexcmd
alexcmd / min-char-rnn.py
Created April 21, 2017 16:28 — forked from karpathy/min-char-rnn.py
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
@alexcmd
alexcmd / latency.txt
Created May 9, 2017 13:21 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
openssl genrsa -des3 -passout pass:x -out server.pass.key 2048
openssl rsa -passin pass:x -in server.pass.key -out server.key
rm server.pass.key
openssl req -new -key server.key -out server.csr
openssl x509 -req -sha256 -days 365 -in server.csr -signkey server.key -out server.crt
@alexcmd
alexcmd / container_handmade.go
Last active June 24, 2017 21:35 — forked from julz/main.go
containersched minicontainer
package main
import (
"fmt"
"os"
"os/exec"
"syscall"
)
func main() {