Skip to content

Instantly share code, notes, and snippets.

View beratdogan's full-sized avatar

Berat Doğan beratdogan

View GitHub Profile
@beratdogan
beratdogan / DisposableClassException.php
Created February 3, 2014 20:34
Defining dispoasble classes with Traits in PHP.
<?php
class DisposableClassException extends \Exception
{}
@beratdogan
beratdogan / turkey_provinces_districts.json
Last active August 29, 2015 13:56
A huge list of provinces and their districts of Turkey in JSON format. Have fun!
[
{
"name":"Adana",
"slug":"adana",
"plate_code":1,
"districts":[
{
"name":"Alada\u011f",
"slug":"aladag"
},
@beratdogan
beratdogan / App.config.xml
Last active August 29, 2015 13:56
Blog Post: .Net2.0 Uygulamalarinin .Net4.0'da Calismamasi
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0.30319" />
</startup>
</configuration>
@beratdogan
beratdogan / TempFileClass.cs
Created March 15, 2014 11:33
C#'ta Exe icine Gomulmus Baska Bir Exe'yi Calistirmak
sealed class TempFile : IDisposable
{
string path;
public TempFile() : this(System.IO.Path.GetTempFileName()) { }
public TempFile(string path)
{
if (string.IsNullOrEmpty(path)) throw new ArgumentNullException("path");
this.path = path;
}
@beratdogan
beratdogan / coffee_watcher.sh
Created April 13, 2014 00:53
Appends seperated .coffee files into one file, and compiles as application.js. So cool, hah?
#!/bin/sh
clear
echo "CoffeeScript watching you!"
coffee -j js/application.js -wc js/
@beratdogan
beratdogan / array_fill
Created April 22, 2014 23:07
Fill arrays in JavaScript.
Array.apply(null, new Array(3)).map(Array.prototype.valueOf, (Array.apply(null, new Array(3)).map(Number.prototype.valueOf, 0)));
@beratdogan
beratdogan / 1_scope.js
Last active August 29, 2015 14:00
[JavaScript][CoffeeScript] Degisken/Fonksiyon Etki Alanlari
$('#menu a').click(function(event)
{
// $(this)
// Bize '#menu a'ya ait tiklanmis olan elementi gosterecektir.
$('#menu li').each(function(index)
{
// $(this)
// Bize '#menu li'ye ait elementleri isaret edecektir.
});
@beratdogan
beratdogan / string_htmlspecialchars.coffee
Last active August 29, 2015 14:01
Coffee type extends
String::htmlspecialchars = (quote_style = 2, double_encode) ->
optTemp = 0
i = 0
noquotes = false
string = @.toString()
string = string.replace(/&/g, '&amp;') if double_encode isnt false
string = string.replace(/</g, '&lt;').replace(/>/g, '&gt;')
@beratdogan
beratdogan / i18n.coffee
Created May 27, 2014 13:35
Google Chrome Extension Utils - with contributions of Limk.com
# You can easly internionalize your extension's HTMLs with this.
$('[data-i18n]').each ->
me = $(@)
key = me.data 'i18n'
switch me.attr 'data-i18n-method'
when 'placeholder'
me.attr 'placeholder', chrome.i18n.getMessage key
@beratdogan
beratdogan / spf.js
Created June 29, 2014 23:08
Compiled and minified spf.js file. Can be found more details here: https://github.com/youtube/spfjs
/*
SPF
(c) 2012-2014 Google, Inc.
License: MIT
*/
(function(){function l(a,b,c){var d=Array.prototype.slice.call(arguments,2);return function(){var c=d.slice();c.push.apply(c,arguments);return a.apply(b,c)}}function aa(a,b){if(a){var c=Array.prototype.slice.call(arguments,1);try{return a.apply(null,c)}catch(d){return d}}}function m(a,b){if(document.createEvent){var c=document.createEvent("CustomEvent");c.initCustomEvent("spf"+a,!0,!0,b);return document.dispatchEvent(c)}return!0}function n(){return(new Date).getTime()};function p(a,b){return q[a]=b}var q=window._spf_state||{};window._spf_state=q;var ba={"animation-class":"spf-animate","animation-duration":425,"cache-lifetime":6E5,"cache-max":50,"cache-unified":!1,"link-class":"spf-link","nolink-class":"spf-nolink","navigate-limit":20,"navigate-lifetime":864E5,"prefetch-on-mousedown":!1,"process-async":!1,"request-timeout":0,"url-identifier":"?spf=__type__"};function r(a){return ca()[a]}function ca(a){return!a&&"config"in q?q.config:p("config",a||{})};function