Skip to content

Instantly share code, notes, and snippets.

@aniljava
aniljava / FontFromBase64.java
Created May 11, 2012 07:50
Convert Base64 Encoded data to Font OTF/TTF
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.nio.ByteBuffer;
public class FontFromBase64 {
public static void main(String[] args) throws Exception {
String infile = "text.txt";
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Iterator;
import java.util.zip.GZIPInputStream;
public class LineReader implements Iterator<String>, Iterable<String> {
/**
* lobste.rs
* Font colors and fonts
*/
li .details .link a{
/*color:#19449c !important;*/
}
li .details .link a:visited{
@aniljava
aniljava / gist:11029173
Last active December 16, 2019 12:58
simple-server
#!/usr/bin/env python2
import BaseHTTPServer
import SocketServer
from StringIO import StringIO
import random
import urllib2 as urllib
import shutil
class Main(BaseHTTPServer.BaseHTTPRequestHandler):
@aniljava
aniljava / greenlet-stdout
Last active November 20, 2017 15:40
Gevent Seperate stdout per spawn
#!/usr/bin/env python2
# There should be a standard way of doing this. For now a hack.
import gevent
import inspect
def one():
print '1'
@aniljava
aniljava / utils.py
Last active August 29, 2015 14:00
PYTHON MASTER LIST OF UTILS
# UUID
import uuid
get_uuid = lambda:uuid.uuid4()
# get_id, string_to_id
toid = lambda data: ''.join(['_', k.lower()][k in '0123456789-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'] for k in data)
# subfolder distribution
import os
#!/usr/bin/env python2
import os
import sys
import commands
import time
import threading
origin_x = 100
origin_y = 600
@aniljava
aniljava / ripgrep.-build.md
Created November 29, 2017 05:54
Could not find `avx` in `x86`
# ./compile
   ...
   Compiling bytecount v0.2.0
   Compiling ripgrep v0.7.1 (file:///xxxx/ripgrep)
error[E0432]: unresolved import `simd::x86::avx`
  --> /xxxx/.cargo/registry/src/github.com-1ecc6299db9ec823/bytecount-0.2.0/src/lib.rs:15:16
   |
15 | use simd::x86::avx::{LowHigh128, u8x32};
   |                ^^^ Could not find `avx` in `x86`
@aniljava
aniljava / letsencrypt
Last active September 13, 2018 15:18
letsencrypt automate script
DOMAIN=$1
wget 'https://raw.githubusercontent.com/Neilpang/acme.sh/master/acme.sh' -O acme.sh
chmod +x acme.sh
./acme.sh --issue -d $DOMAIN --standalone -d www.$DOMAIN --home ./
cp $DOMAIN/$DOMAIN.cer ./crt.crt
cp $DOMAIN/$DOMAIN.key ./key.key
cp $DOMAIN/fullchain.cer ./chain.crt