Skip to content

Instantly share code, notes, and snippets.

View vyuh's full-sized avatar

Prashant Karmakar vyuh

View GitHub Profile
@vyuh
vyuh / setup_split_internet_access.sh
Created September 27, 2016 09:06
sets up internet traffic balancing over multiple interfaces
# sets up internet traffic balancing over multiple interfaces
# used on Lubuntu 16.04
# 2016-09-27 14:29 http://github.com/vyuh
#
# Read the webpage:
# http://lartc.org/howto/lartc.rpdb.multiple-links.html
# Change variables below to proper values,
# run this as root like `sudo bash +x <script_name>`
# `-x` aids debugging
#
(define hey (lambda () "the ultimate"))
(define pk (quote (special-forms "quote" "lambda" "define" "if" "set!")))
(define hey_pk (lambda (pk) (string-append "Hey " pk)))
(define mod_zed (lambda (x y) (+ (* x x) (* y y))))
(define test (lambda (x) (if x "yo" "no")))
; everything except #f is true
; in some implementations '() is equivalent to #f
; but do not use lists as predicates
; use null? to find empty lists
(define sum-gp
@vyuh
vyuh / jekyll_touch.sh
Created May 15, 2016 21:11
rename a file like a jekyll post dated today
#!/bin/sh
# rename a file like a jekyll post dated today
date_filename () {
sep='/';
local file=`basename "$1"`;
local dir=`dirname "$1"`;
local date=`date +%F`;
local bare=`echo "$file" | sed 's/^20\([0-9]\{2\}-\)\{3\}//'`
mv "$1" "$dir$sep$date-$bare";
@vyuh
vyuh / box2d_build.sh
Created April 21, 2016 13:04
Build Box2d 2.3.0 on Ubuntu
git clone https://github.com/erincatto/Box2D
cd Box2D/Box2D
git branch pk v2.3.0
git checkout pk
cmake .
make
Testbed/Testbed &
@vyuh
vyuh / captchagen
Created March 5, 2016 14:57
Generate Image for CAPTCHA
#!/usr/bin/perl
$r = join "", map { ( "a".."z", "A".."Z", "0".."9" )[rand 62] } 1..9;
system( qq/convert -size 300x100 -font Courier -gravity center "label:$r" label.bmp/ );
system( q/convert -size 150x50 xc:gray +noise random -blur 1x1 -colorspace gray -scale 300x100 gray.bmp/ );
system( q/convert label.bmp gray.bmp -compose displace -define compose:args=12x12 -composite -blur 1x1 comp.png/ );
@vyuh
vyuh / emoji.md
Last active November 24, 2015 17:44 — forked from mmulich/emoji.md
emoji

EMOJI CHEAT SHEET

People

:bowtie: 😄 😆 😊 😃 ☺️

@vyuh
vyuh / sentence.sh
Last active November 24, 2015 17:34
Filter english text files to one sentence per line.
perl -M'Lingua::EN::Sentence qw/get_sentences/' -00 -lne 'tr/\r\n \t/ /s;print join "\n", @{get_sentences $_};'
@vyuh
vyuh / sort_bookmarks_html.pl
Last active August 29, 2015 14:24
Fetches all links as of now. eventually, i want it to remove duplicate bookmarks and then sort them
#!/usr/bin/perl
use HTML::TreeBuilder::XPath;
my $file = shift; # first argument is bookmarks HTML filepath
my $tree = new HTML::TreeBuilder::XPath;
$tree->parse_file($file);
use Data::Dumper;
my @links = $tree->findnodes('//a');
use List::Flatten;
print join ' ', flat @{$_}{ qw/href _content/ }, "\n" for (@links);
#woah http://www.perlmonks.org/?node=References%20quick%20reference
@vyuh
vyuh / geometry_pk.py
Created April 2, 2015 16:58
Antialiased Geometric constructions
#-------------------------------------------------------------------------------
# Name: geometry_pk
# Purpose: Simple approach to implementing antialiased graphics.
#
# Author: pk
#
# Created: 30-03-2015
# Copyright: (c) pk 2015
# Licence: ISC
#-------------------------------------------------------------------------------
@vyuh
vyuh / inset_image.html
Created March 18, 2015 05:49
To inset an image into another. Like a profile photo over banner photo. whim.png is 1500x500. t_pic.jpg 353x353. Only aspect ratios are important.
<html>
<head>
<title>Page Title</title>
<style>
.description {
font-family: Georgia, serif;
font-size: .85em;
text-align: center;
}
.wrapper {