Skip to content

Instantly share code, notes, and snippets.

View ferhatelmas's full-sized avatar
🚀

ferhat elmas ferhatelmas

🚀
View GitHub Profile
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
@ferhatelmas
ferhatelmas / tree.md
Last active August 29, 2015 14:17 — forked from hrldcpr/tree.md

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!

@ferhatelmas
ferhatelmas / introrx.md
Last active August 29, 2015 14:18 — forked from staltz/introrx.md

The introduction to Reactive Programming you've been missing

(by @andrestaltz)

So you're curious in learning this new thing called Reactive Programming, particularly its variant comprising of Rx, Bacon.js, RAC, and others.

Learning it is hard, even harder by the lack of good material. When I started, I tried looking for tutorials. I found only a handful of practical guides, but they just scratched the surface and never tackled the challenge of building the whole architecture around it. Library documentations often don't help when you're trying to understand some function. I mean, honestly, look at this:

Rx.Observable.prototype.flatMapLatest(selector, [thisArg])

Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.

@ferhatelmas
ferhatelmas / s3.sh
Last active August 29, 2015 14:21 — forked from chrismdp/s3.sh
# You don't need Fog in Ruby or some other library to upload to S3 -- shell works perfectly fine
# This is how I upload my new Sol Trader builds (http://soltrader.net)
# Based on a modified script from here: http://tmont.com/blargh/2014/1/uploading-to-s3-in-bash
S3KEY="my aws key"
S3SECRET="my aws secret" # pass these in
function putS3
{
path=$1
@ferhatelmas
ferhatelmas / goshebang.md
Created July 6, 2015 20:05
Run go file as a shebang

Add //usr/bin/env go run $0 $@; exit to go file to run like a shell script

$ cat a.go
//usr/bin/env go run $0 $@; exit

package main

import "fmt"
@ferhatelmas
ferhatelmas / mandelbrot.sql
Last active August 29, 2015 14:25 — forked from rupey/mandelbrot.sql
Mandelbrot plot in postgres
WITH RECURSIVE
x(i) AS ( VALUES (0)
UNION ALL SELECT i + 1
FROM x
WHERE i < 101),
Z(Ix, Iy, Cx, Cy, X, Y, I) AS (
SELECT
Ix,
Iy,
X :: FLOAT,
@ferhatelmas
ferhatelmas / vineScrape.go
Last active August 29, 2015 14:25 — forked from cryptix/vineScrape.go
extract a javascript object value from a html page using goquery and otto
package main
import (
"errors"
"log"
"os"
"github.com/PuerkitoBio/goquery"
"github.com/robertkrimen/otto"
)
@ferhatelmas
ferhatelmas / gmail.py
Last active August 29, 2015 14:26 — forked from jasonrdsouza/gmail.py
Python script to access a gmail account and download particular emails
import email, getpass, imaplib, os
detach_dir = '.' # directory where to save attachments (default: current)
user = raw_input("Enter your GMail username:")
pwd = getpass.getpass("Enter your password: ")
# connecting to the gmail imap server
m = imaplib.IMAP4_SSL("imap.gmail.com")
m.login(user,pwd)
m.select("cs2043") # here you a can choose a mail box like INBOX instead
@ferhatelmas
ferhatelmas / csv.sql
Created October 28, 2015 21:37 — forked from nepsilon/postgres-import-export-csv.md
Importing and Exporting CSV files with PostgreSQL
-- Import CSV into table t_words
COPY t_words FROM '/path/to/file.csv' DELIMITER ',' CSV;
-- You can tell quote char with QUOTE
-- and change delimiter with DELIMITER
-- Import CSV into table t_words,
-- telling what columns to use
COPY t_words("name", "count", "def") FROM 'file.csv' DELIMITER ',' CSV;
-- Export table to a CSV file
@ferhatelmas
ferhatelmas / fakenames.csv
Last active January 23, 2016 00:02
Fictional character names that might be useful for testing
name surname
Charlie Brown
Peppermint Patty
Sally Brown
Violet Gray
Faye Hudson
Cameron Hudson
Doug Willis
Pam Willis
Gaby Willis