Skip to content

Instantly share code, notes, and snippets.

View evandrix's full-sized avatar
💭
offline

evandrix evandrix

💭
offline
View GitHub Profile
[www]
ping.path = /ping
@evandrix
evandrix / read-file.sh
Created June 26, 2013 00:31
Correct way to read file line-by-line
k=1
while read line;do
echo "Line # $k: $line"
((k++))
done < $FILE
echo "Total number of lines in file: $k"
data FreeF f a x = Pure a | Free (f x)
newtype FreeT f m a =
FreeT { runFreeT :: m (FreeF f a (FreeT f m a)) }
instance (Functor f, Monad m) => Monad (FreeT f m) where
return a = FreeT (return (Pure a))
FreeT m >>= f = FreeT $ m >>= \v -> case v of
Pure a -> runFreeT (f a)
Free w -> return (Free (fmap (>>= f) w))

Transparent Git Encryption

This document has been modified from its [original format][m1], which was written by Ning Shang (geek@cerias.net). It has been updated and reformatted into a [Markdown][m2] document by [Woody Gilk][m3] and [republished][m4].

Description

When working with a remote git repository which is hosted on a third-party storage server, data confidentiality sometimes becomes

@evandrix
evandrix / index.html
Created April 23, 2013 14:14
A CodePen by suffick. Tear-able Cloth - Javascript cloth simulation.
<canvas id = "c" > </canvas>
<a target="_blank" href="http://codepen.io/stuffit/pen/fhjvk" id="p">New pen: Like playing with physics? Click here!</a>
<div id="info">
<div id="top">
<a target="_blank" id="site" href="http://lonely-pixel.com">my website</a>
<a id="close" href="">close</a>
</div>
<p>
@evandrix
evandrix / pr.md
Created March 25, 2013 09:53 — forked from piscisaureus/pr.md

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@evandrix
evandrix / README
Created March 20, 2013 09:21 — forked from utkarshl/README
In order to use segtree class defined above, you will need to create a datatype(a struct most likely), which will implement the function merge(). It can also additionally implement split, if you need to define the split operation.
A sample is shown as "struct segtree_node" in the code above.
The segtree has to be instantiated with this defined data type. For example,as
segtree<segtree_node> s;
You have to first call the init function of the class, which will take
int n=number of elements in your array,
node[] = your inital array,
identity = an element such that merge(y,identity) = merge(identity,y) = y for all y's.
@evandrix
evandrix / pyqt4-uic.py
Created March 4, 2013 05:15
PyQt4 + load pyuic4-generated *.ui -> *.py
import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from <REPLACE_BY_PYUI_DESIGN> import <REPLACE_BY_WINDOW_CLASS_IN_PYUI_DESIGN>
class MainWindow(QMainWindow, <REPLACE_BY_WINDOW_CLASS_IN_PYUI_DESIGN>):
# custom slot
@evandrix
evandrix / int_partition.cpp
Created February 26, 2013 07:51
Generating all partitions of a given number: A partition of a positive integer number "n" is a way of writing "n" as a sum of positive integers.
#include <iostream>
// Output a partition:
void output_partition(const int n, const int *x, const int how_many_partitions)
{
std::cout << "Partition(" << how_many_partitions << ")" << " = ";
for (int i = 1; i <= n; i++)
{
// Can't show negative numbers:
if (x[i] > 0)
*filter
# Allow all loopback (lo0) traffic and drop all traffic to 127/8 that doesn't use lo0
-A INPUT -i lo -j ACCEPT
-A INPUT ! -i lo -d 127.0.0.0/8 -j REJECT
# Accept all established inbound connections
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
# Allow all outbound traffic - you can modify this to only allow certain traffic