Skip to content

Instantly share code, notes, and snippets.

View prakhar1989's full-sized avatar
I may be slow to respond.

Prakhar Srivastav prakhar1989

I may be slow to respond.
View GitHub Profile
  1. General Background and Overview
@prakhar1989
prakhar1989 / nginx-fpm.md
Last active August 29, 2015 14:05
Nginx + PHP-FPM

Configurations

Service Config Folder Config File
Nginx /etc/nginx/ /etc/nginx/nginx.conf
PHP FPM /etc/php-fpm.d/ /etc/php.fpm.conf
PHP (extn) /etc/php.d/ /etc/php.ini

PHP FPM Configuration

@prakhar1989
prakhar1989 / game.py
Created August 30, 2014 19:01
Game
import random
if __name__ == "__main__":
# this decides whether the user wants to continue
choice = True
# the main game loop
while choice:
print "Random number: " + str(random.random() * 100)
print "Do you want to continue? Y/N?: ",
user_choice = raw_input()
// generates a pair of colors separated by alpha controlled by a level
private Pair<Integer, Integer> getRandomColor(int level) {
int red = (int)(Math.random() * 255);
int green = (int)(Math.random() * 255);
int blue = (int)(Math.random() * 255);
// factor in level
int alpha1 = 200 + (int)(Math.random() * 55);
int delta = (10 - level) * 5;
int alpha2 = alpha1 > 227 ? alpha1 - delta : alpha1 + delta;
@prakhar1989
prakhar1989 / matasano.go
Created August 12, 2014 16:01
Matasano Crypto
package main
import (
"fmt"
"encoding/hex"
"encoding/base64"
)
func main() {
s := "1c0111001f010100061a024b53535009181c"
@prakhar1989
prakhar1989 / strings.go
Created August 12, 2014 10:19
Understanding Strings
package main
import "fmt"
func main() {
//const sample = "\xbd\xb2\x3d\xbc\x20\xe2\x8c\x98"
//const sample = "Hello"
// sample as a slice of bytes
sample := []byte{'H', 'e', 'l', 'l', 'o'}
// Karma configuration
// Generated on Mon Jul 07 2014 02:15:03 GMT+0300 (AST)
module.exports = function(config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '../',
def reverse(seq):
""" retruns the reverse of a seqence """
return seq[::-1]
(*>* Problem 5 *>*)
(* few_divisors n m should return true if n has fewer than m divisors,
* (including 1 and n) and false otherwise: *)
few_divisors 17 3;;
- : bool = true
# few_divisors 4 3;;
- : bool = false
# few_divisors 4 4;;
- : bool = true
let max_length header rows =
let lengths list = List.map ~f:String.length list in
List.fold rows
~init: (lengths header)
~f: (fun acc row ->
List.map2_exn ~f:Int.max acc (lengths row))
let make_separator widths =
let pieces = List.map widths
~f:(fun w -> String.make (w + 2) '-') (* padding of 2 chars *)