Skip to content

Instantly share code, notes, and snippets.

View andreis's full-sized avatar

andreis

View GitHub Profile
@pesterhazy
pesterhazy / git-ag
Created March 1, 2014 17:55
Search your git repository using ag (the silver searcher)
#!/bin/bash
# Put additional ignore patterns (one by line) in .grepignore
#
git-ag () {
if [[ "$1" = "-a" ]]
then
all=1
shift
typedef struct chan_t
{
pthread_mutex_t m_mu;
pthread_cond_t m_cond;
int closed;
void (* dispose)(struct chan_t * self);
...
} chan_t;
func (self *Security) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc) {
// Browser CORS
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS
// http://www.html5rocks.com/en/tutorials/cors/
origin := r.Header.Get(mjdlib.HttpHeaderKeyOrigin);
// Browser CORS Origin: a Preflight Request (OPTIONS)
if r.Method == "OPTIONS" {
mjdlib.LogInfo("**CORS OPTIONS URL %v: \n request = %v\n", r.RequestURI, r)
@JosephRedfern
JosephRedfern / Speedtest
Last active September 16, 2015 21:35
Scaleway ARM machine
root@beryllium:~# wget http://cachefly.cachefly.net/100mb.test
converted 'http://cachefly.cachefly.net/100mb.test' (ANSI_X3.4-1968) -> 'http://cachefly.cachefly.net/100mb.test' (UTF-8)
--2015-09-03 11:28:49-- http://cachefly.cachefly.net/100mb.test
Resolving cachefly.cachefly.net (cachefly.cachefly.net)... 62.210.187.96
Connecting to cachefly.cachefly.net (cachefly.cachefly.net)|62.210.187.96|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 104857600 (100M) [application/octet-stream]
Saving to: '100mb.test'
100mb.test 100%[==========================================================================================================================================>] 100.00M 50.1MB/s in 2.0s
anonymous
anonymous / db.go
Created January 24, 2012 17:39
Go SDK for Dropbox
package dropbox
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
"strconv"

This is total shit quickly banged out in probably hard to follow semi-formalism.

TL/DR part, skip to next section

Complex numbers (C) can be viewed as a scalar bivector pair. A 2D bivector requires 1 element (note 1), so we have C ~= R1+R1 ~= R2 with basis {1,i}.

Denote a complex number: z = a+bi = (a, b), {a,b} on R. Associating C with R2 we can interpret (a,b) as a coordinate (in the plane). Functions over C map coordinates in the plane to other coordinates in the plane. We can define principle value (single valued) functions for: log, exp and powers (among others).

For power we can rewrite 'z' into a polar form z = m(cos(a), sin(a)), m >= 0, a on [pi,-pi). Then the princle power can be denoted as:

zt = mt(cos(ta), sin(ta))

@nf
nf / analyze.go
Last active January 12, 2016 21:14
'spent' script to log where time is spent
package main
import (
"bufio"
"fmt"
"net/url"
"os"
"regexp"
"sort"
"strconv"
@cecilemuller
cecilemuller / readme.md
Last active January 29, 2016 15:09
Let's encrypt (Nginx, Ubuntu 14.04 LTS)

Install the client:

apt-get install git
git clone https://github.com/letsencrypt/letsencrypt
cd letsencrypt

Generate certificates using manual mode:

@houmei
houmei / bcdall0.v
Created January 27, 2013 16:52
FizzBuzz by FPGA DE0 (QuartusII,verilog)
module bcdall0(BCD3,BCD2,BCD1,BCD0, lampoff);
input [3:0] BCD3;
input [3:0] BCD2;
input [3:0] BCD1;
input [3:0] BCD0;
output lampoff;
assign lampoff=(BCD0==4'd0)&(BCD1==4'd0)&(BCD2==4'd0)&(BCD3==4'd0);
endmodule
@chalmagean
chalmagean / onSelect.elm
Last active December 22, 2016 06:21
Elm onSelect decoder
-- Assuming we have a list of items in the model (type alias Model = { items : List Item }
-- where Item is a record like { id : Int, name : String }
-- this goes in the view and generates an html dropdown
select
[ onSelect ValueSelectedMsg ]
(List.map (\item -> option [ value (toString item.id) ] [ text item.name ]) model.items)
targetSelectedIndex : Json.Decoder Int