Skip to content

Instantly share code, notes, and snippets.

Avatar
🌝
Ba Dum Tsh!

Serkan Yerşen serkanyersen

🌝
Ba Dum Tsh!
View GitHub Profile
@serkanyersen
serkanyersen / precommit.sh
Created Oct 29, 2018
Run static checks and build on githooks. Bash script with progress display
View precommit.sh
#!/bin/bash
######################################
## Utilities
######################################
success () {
printf "\r\033[2K [ \033[00;32mOK\033[0m ] $1\n"
}
info () {
@serkanyersen
serkanyersen / javascript.json
Last active Jun 23, 2017
Eslint snippets for VSCODE
View javascript.json
{
"eslint/disable": {
"prefix": "eslint-disable",
"description": "To temporarily disable rule warnings in your file",
"body": [
"/* eslint-disable $rules */"
]
},
"eslint/enable": {
"prefix": "eslint-enable",
View keybase.md

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 / geo_distance.js
Last active Aug 29, 2015
Get Distance From Latitude and Longitude in Kilometers
View geo_distance.js
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 / get-annotations.js
Created Apr 25, 2014
reads all the annotations from google developers youtube channel and extracts goo.gl links
View get-annotations.js
// 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 / examples.js
Created Sep 29, 2013
Allows you to correctly extend existing models and views while utilizing the properties on the base object, also adds super class support
View examples.js
var Car = Backbone.Model.extend({
defaults:{
engine: 'gasoline',
hp: 0,
doors: 4,
color: 'generic'
},
engine: function(){
return 'Wroomm';
}
View tmux_cheatsheet.markdown

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

View autoload.php
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
@serkanyersen
serkanyersen / User.sublime-keymap.json
Created Mar 26, 2012
sublime: windows/linux keymap
View User.sublime-keymap.json
[
/* 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
View User.sublime-keymap.json
[
/* 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"}},