Skip to content

Instantly share code, notes, and snippets.

View rayyildiz's full-sized avatar
🎯
Focusing

Ramazan AYYILDIZ rayyildiz

🎯
Focusing
View GitHub Profile
@rayyildiz
rayyildiz / 0_reuse_code.js
Last active August 28, 2015 07:39
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console

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.

import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
public abstract class AbstractSQLiteSupport {
protected SQLiteDatabase db;
public AbstractSQLiteSupport(SQLiteDatabase db) {
this.db = db;
@rayyildiz
rayyildiz / gist:1127182
Created August 5, 2011 09:19
Copy stream
public class StreamHelper{
public static void copy(InputStream in, OutputStream out) throws IOException {
byte[] barr = new byte[1024];
while(true) {
int r = in.read(barr);
if (r <= 0) {
break;
}
out.write(barr, 0, r);
@rayyildiz
rayyildiz / gist:2027501
Created March 13, 2012 07:53
Generate LiquiBase changeLogs using Groovy
def writer = new FileWriter('sample2.xml')
// Define 2 tables
def tables =[]
def dept = new Table(tableName:'departments')
dept.columns << new Column(name:'id', type:'number(4,0)', nullable:false)
dept.columns << new Column(name:'dname', type:'varchar2(14)', remarks:'Department name')
tables << dept
def emp = new Table(tableName:'employees', remarks:'All employees known in HR system')
@rayyildiz
rayyildiz / palindromicNumbers.hs
Last active August 6, 2016 16:55
Palindromic Numbers in Haskell
[x*y | x<-[10..99], y<- [10..99], reverse(show(x*y))==show(x*y)]
@rayyildiz
rayyildiz / ProjectEuler2.hs
Last active September 5, 2016 07:13
Even Fibonacci numbers (Project Euler Question 2)
fib :: Integer -> Integer
fib 0 = 1
fib 1 = 1
fib n = fib (n-1) + fib (n-2)
fibs = take 40 (1 : 1 : zipWith (+) fibs (tail fibs))
fibResult = sum [x | x <- fibs, x < 4000000, x `mod` 2 == 0 ]
@rayyildiz
rayyildiz / ProjectEuler1.hs
Last active September 5, 2016 07:14
Multiples of 3 and 5 (Project Euler Question 1)
sum1 = sum [x| x <- [1..9], x `mod` 3 == 0 || x `mod` 5 == 0]
sum2 = sum [x| x <- [1..999], x `mod` 3 == 0 || x `mod` 5 == 0]
@rayyildiz
rayyildiz / ProjectEuler4.hs
Created September 5, 2016 07:16
Largest palindrome product (Project Euler Question 4)
palindromicNumbers = [x*y | x<-[1..999], y<- [1..999], reverse(show(x*y))==show(x*y)]
@rayyildiz
rayyildiz / ProjectEuler3.hs
Created September 5, 2016 07:14
Largest prime factor (Project Euler Question 3)
isPrime :: Integer->Bool
isPrime x = null [y | y<-[2..floor (sqrt (fromIntegral x))], x `mod` y == 0]
divPrime n = [x | x <- [1..n], n `mod` x == 0 && isPrime x]