Skip to content

Instantly share code, notes, and snippets.

View serkanyersen's full-sized avatar
🌝
Ba Dum Tsh!

Serkan Yerşen serkanyersen

🌝
Ba Dum Tsh!
View GitHub Profile
@serkanyersen
serkanyersen / ie.js
Last active September 28, 2015 00:38 — forked from padolsey/gist:527683
Javascript: Detect IE
// ----------------------------------------------------------
// A short snippet for detecting versions of IE in JavaScript
// without resorting to user-agent sniffing
// ----------------------------------------------------------
// If you're not in IE (or IE version is less than 5) then:
// ie === undefined
// If you're in IE (>=5) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}
@serkanyersen
serkanyersen / User.sublime-keymap.json
Created March 26, 2012 18:33
sublime: os x keymap
[
/* Mac os x does not use home / end keys like windows. These keys fixes this behavior */
// Move selection to beggining of the line, windows style
{ "keys": ["shift+home"], "command": "move_to", "args": {"extend":true, "to": "bol"}},
// Move selection to end of the line, windows style
{ "keys": ["shift+end"], "command": "move_to", "args": {"extend":true, "to": "eol"}},
// Move cursor to beggining of the line, windows style
{ "keys": ["home"], "command": "move_to", "args": {"to": "bol"}},
// Move cursor to end of the line, windows style
{ "keys": ["end"], "command": "move_to", "args": {"to": "eol"}},
@serkanyersen
serkanyersen / User.sublime-keymap.json
Created March 26, 2012 18:37
sublime: windows/linux keymap
[
/* Eclipse keys */
// Go to anything menu
{ "keys": ["ctrl+t"], "command": "show_overlay", "args": {"overlay": "goto", "show_files": true} },
// Shift+Enter to add a new line without going to end of the line
{ "keys": ["shift+enter"], "command": "run_macro_file", "args": {"file": "Packages/Default/Add Line.sublime-macro"} },
// Move lines up and down
{ "keys": ["alt+up"], "command": "swap_line_up" },
{ "keys": ["alt+down"], "command": "swap_line_down" },
// Close all tabs without closing sublime
@serkanyersen
serkanyersen / autoload.php
Created April 2, 2012 06:59
PHP: __autoload
function __autoload($class_name) {
# If file name contains underscore convert them to folder marks
if (strpos($class_name, '_') !== false) {
$className = str_replace("_", "/", $class_name);
} else {
$className = $class_name;
}
# This where we usually contain all our classes

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@serkanyersen
serkanyersen / examples.js
Created September 29, 2013 21:57
Allows you to correctly extend existing models and views while utilizing the properties on the base object, also adds super class support
var Car = Backbone.Model.extend({
defaults:{
engine: 'gasoline',
hp: 0,
doors: 4,
color: 'generic'
},
engine: function(){
return 'Wroomm';
}
@serkanyersen
serkanyersen / get-annotations.js
Created April 25, 2014 00:42
reads all the annotations from google developers youtube channel and extracts goo.gl links
// 1. load up youtube.com
// 2. open console and run this code
var jq = document.createElement('script');
jq.src = "https://code.jquery.com/jquery-latest.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);
// After that code has run, copy paste the following code and check results in console.
// Don't forget to add your own API key there
@serkanyersen
serkanyersen / geo_distance.js
Last active August 29, 2015 14:23
Get Distance From Latitude and Longitude in Kilometers
function getDistanceFromLatLonInKm(lat1, lon1, lat2, lon2) {
var R = 6371, // Radius of the earth in km
dLat = deg2rad(lat2 - lat1), // deg2rad below
dLon = deg2rad(lon2 - lon1),
a = Math.sin(dLat / 2) * Math.sin(dLat / 2) +
Math.cos(deg2rad(lat1)) * Math.cos(deg2rad(lat2)) *
Math.sin(dLon / 2) * Math.sin(dLon / 2),
c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)),
d = R * c; // Distance in km
@serkanyersen
serkanyersen / keybase.md
Created July 15, 2016 00:25
Keybase Proof

Keybase proof

I hereby claim:

  • I am serkanyersen on github.
  • I am serkanyersen (https://keybase.io/serkanyersen) on keybase.
  • I have a public key ASDGZSxXT6lhgn0GblngxWpqpTvJd_2qFA8mDR8eZYcG9Ao

To claim this, I am signing this object:

@serkanyersen
serkanyersen / javascript.json
Last active July 8, 2021 01:34
Eslint snippets for VSCODE
{
"eslint/disable": {
"prefix": "eslint-disable",
"description": "To temporarily disable rule warnings in your file",
"body": [
"/* eslint-disable $rules */"
]
},
"eslint/enable": {
"prefix": "eslint-enable",