Skip to content

Instantly share code, notes, and snippets.

View cbguder's full-sized avatar

Can Berk Güder cbguder

View GitHub Profile
@cbguder
cbguder / weibull.c
Created March 7, 2011 15:43
Weibull distribution
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
float randomf() {
return (float)random() / (float)RAND_MAX;
}
float weibull(float alpha, float beta) {
float u = 1.0 - randomf();
@cbguder
cbguder / 960gs.jsx
Created December 22, 2010 13:32
960gs ExtendScript for Adobe Photoshop CS5
/*
* 960gs ExtendScript for Adobe Photoshop CS5
* Copyright (c) 2010 Can Berk Güder
*/
#target photoshop
var doc;
var w = new Window(
"dialog {\
@cbguder
cbguder / verifyReceipt.py
Created September 23, 2010 21:42
Verify in-app purchase receipts
#!/usr/bin/env python
import sys
import json
import base64
import urllib2
liveURL = 'https://buy.itunes.apple.com/verifyReceipt'
sandboxURL = 'https://sandbox.itunes.apple.com/verifyReceipt'
def random_password(len)
chars = ("a".."z").to_a + ("0".."9").to_a
result = ""
1.upto(len) { |i| result << chars[rand(chars.size-1)] }
return result
end
def age
age = Date.today.year - self.birthday.year
if Date.today < self.birthday.advance(:years => age)
age -= 1
end
return age
end
def yaziyla(amount)
r = ''
if amount >= 2000
r += yaziyla_part(amount / 1000) + 'BİN'
elsif amount >= 1000
r += 'BİN'
end
r += yaziyla_part(amount % 1000) + ' TL'
kurus = (amount * 100) % 100
function turkishUpperCase(s) {
s = s.replace(/ı/g, 'I');
s = s.replace(/i/g, 'İ');
return s.toUpperCase();
}
function fixSmallCaps(selector) {
$$(selector).each(function(e) {
var text = e.innerHTML;
var upper = turkishUpperCase(text);