Skip to content

Instantly share code, notes, and snippets.

View ShikherVerma's full-sized avatar
👔
सख्त लौंडा

Shikher Verma ShikherVerma

👔
सख्त लौंडा
  • Earth
View GitHub Profile
@ShikherVerma
ShikherVerma / git-http-server.js
Created July 27, 2017 12:34
minimal git http server with npm modules : http, child_process, path, git-http-backend, zlib
var http = require('http');
var spawn = require('child_process').spawn;
var path = require('path');
var backend = require('git-http-backend');
var zlib = require('zlib');
var server = http.createServer(function (req, res) {
var repo = req.url.split('/')[1];
var dir = path.join(__dirname, 'repos', repo);
var reqStream = req.headers['content-encoding'] == 'gzip' ? req.pipe(zlib.createGunzip()) : req;
@ShikherVerma
ShikherVerma / git-http-server.js
Last active July 27, 2017 12:35
minimal git http server. Run with `node git-http-server.js` (npm modules : http, child_process, path, git-http-backend, zlib)
var http = require('http');
var spawn = require('child_process').spawn;
var path = require('path');
var backend = require('git-http-backend');
var zlib = require('zlib');
var server = http.createServer(function (req, res) {
var repo = req.url.split('/')[1];
var dir = path.join(__dirname, 'repos', repo);
var reqStream = req.headers['content-encoding'] == 'gzip' ? req.pipe(zlib.createGunzip()) : req;
@ShikherVerma
ShikherVerma / verify-certificate.py
Last active July 27, 2017 12:45
verify git push ceritifcates $ verify-certificate.py path-to-latest-push-certificate
import sys
import os
import zlib
import re
import gnupg
import subprocess
def verify_signature(gpg, signature, content):
"""This function exists because python-gnupg failed me."""
# write signature to a file and get file stream 'rb'
@ShikherVerma
ShikherVerma / xdoscript.sh
Created July 27, 2017 12:49
A xdotool script to insert Tab in 600 lines. Just an example for future me. I don't remember where I used this script.
#!/bin/bash
WID=`xdotool search --title "Chromium" | head -1`
xdotool windowfocus $WID
for i in {1..600}
do
xdotool key Tab
xdotool key Enter
sleep 4
done
@ShikherVerma
ShikherVerma / Solution.java
Created July 27, 2017 12:53
Example Java program. Compile and run : javac Solution.java ; java Solution [args]
import java.io.*;
import java.util.*;
import java.math.*;
public class Solution {
private static final String TAG = Solution.class.getName();
public static void main(String... args) {
for(String s : args)
System.out.println(s);
}
@ShikherVerma
ShikherVerma / test.c
Created July 27, 2017 13:02
Example C program. gcc test.c; ./a.out; This verifies that strlen on unsigned char array gives the length of content and not the length of array.
#include <stdio.h>
#include <string.h>
static unsigned char push_cert_sha1[20];
int main() {
printf("Length = %d", strlen(push_cert_sha1));
sprintf(push_cert_sha1, "Hello");
printf("Length = %d", strlen(push_cert_sha1));
}
'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
public class MainActivity extends Activity {
@BindView(R.id.text)
TextView text;
@Override
private static Unbinder createBinding(@NonNull Object target, @NonNull View source) {
Class<?> targetClass = target.getClass();
if (debug) Log.d(TAG, "Looking up binding for " + targetClass.getName());
Constructor<? extends Unbinder> constructor = findBindingConstructorForClass(targetClass);
...
private static Constructor<? extends Unbinder> findBindingConstructorForClass(Class<?> cls) {
Constructor<? extends Unbinder> bindingCtor = BINDINGS.get(cls);
if (bindingCtor != null) {
if (debug) Log.d(TAG, "HIT: Cached in binding map.");
return bindingCtor;
}
String clsName = cls.getName();
if (clsName.startsWith("android.") || clsName.startsWith("java.")) {
if (debug) Log.d(TAG, "MISS: Reached framework class. Abandoning search.");
return null;