Skip to content

Instantly share code, notes, and snippets.

@keune
keune / xkcd-emailer.sh
Created October 23, 2016 19:40
Send yourself latest XKCD comic as email.
#! /bin/bash
# We'll keep the ID of last sent comic here
logFile='./xkcd-last-sent.log'
toEmail='your_email@example.com'
function getJsonVal() {
python -c "import json,sys;sys.stdout.write(json.dumps(json.load(sys.stdin)['$1']))";
}
### Keybase proof
I hereby claim:
* I am keune on github.
* I am keune (https://keybase.io/keune) on keybase.
* I have a public key ASBLSNiPbmWGkjXTRamuMcYeIsqOHzLb1DM2mIA04DAZzAo
To claim this, I am signing this object:
@keune
keune / IMDBSeasonRating.user.js
Last active October 3, 2016 05:20
IMDB Season Rating
// ==UserScript==
// @name IMDB Season Rating
// @namespace http://ahmetkun.com/
// @version 0.1
// @description calculate the rating of a tv show's seasons by episode ratings.
// @author Ahmet Kun
// @match http://www.imdb.com/title/*/eprate*
// @grant none
// ==/UserScript==
@keune
keune / intRange.js
Created January 10, 2015 18:29
Returns an array, containing integers between min and max, including min and max
/*
* Returns an array, containing integers between min and max, including min and max
*/
function range(min, max) {
if(typeof min !== 'number' || typeof max !== 'number' || isNaN(min) || isNaN(max)) return [];
if(min > max) {
var tmp = min;
min = max;
max = tmp;
}
@keune
keune / stringAdd.js
Last active August 29, 2015 14:12
Sum strings as numbers
function stringAdd(a, b) {
/*
* Adds two numbers, in a way you would do with pen and paper
* Since the numbers are kept as strings, it can handle really big numbers
* Useful when you need to calculate sum of two big integers that are bigger than Number.MAX_SAFE_INTEGER
*/
a += '' , b += '';
var res = [], carry = 0, lena = a.length, lenb = b.length;
if(lena > lenb) {
b = new Array(lena - lenb + 1).join('0') + b;
@keune
keune / RollingStone Top 500 Song
Created May 25, 2014 16:55
Json list of Rolling Stone's 500 greatest songs of all time
{"lastUpdateDate":"2014-05-25","data":[{"position":"1","artistTitle":"Bob Dylan","songTitle":"Like a Rolling Stone"},{"position":"2","artistTitle":"The Rolling Stones","songTitle":"(I Can\\'t Get No) Satisfaction"},{"position":"3","artistTitle":"John Lennon","songTitle":"Imagine"},{"position":"4","artistTitle":"Marvin Gaye","songTitle":"What\\'s Going On"},{"position":"5","artistTitle":"Aretha Franklin","songTitle":"Respect"},{"position":"6","artistTitle":"The Beach Boys","songTitle":"Good Vibrations"},{"position":"7","artistTitle":"Chuck Berry","songTitle":"Johnny B. Goode"},{"position":"8","artistTitle":"The Beatles","songTitle":"Hey Jude"},{"position":"9","artistTitle":"Nirvana","songTitle":"Smells Like Teen Spirit"},{"position":"10","artistTitle":"Ray Charles","songTitle":"What\\'d I Say"},{"position":"11","artistTitle":"The Who","songTitle":"My Generation"},{"position":"12","artistTitle":"Sam Cooke","songTitle":"A Change Is Gonna Come"},{"position":"13","artistTitle":"The Beatles","songTitle":"Yesterday"
@keune
keune / make-palindrome.js
Last active February 11, 2021 17:57
Remove a letter to make a palindrome
function tryToGetPalinDrome(str) {
// Returns -2 if the given word is already a palindrome
// Returns -1 if it is impossible to make a palindrome by removing one letter from the given word
// Returns a positive integer that shows the position of the character to remove from the word to make a palindrome
if(str === reverse(str)) return -2; // already a palindrome
var strlen = str.length;
for(var i=0; i<strlen; i++) {
var partial = str.substring(0, i) + str.substring(i+1, strlen);
var reversed = reverse(partial);
if(partial === reversed) {
function findDigit(given) {
// log all the numbers in specified scope that contain a given digit
for (var i = 100; i >= -100; i--) {
var absI = Math.abs(i);
var numberOfDigits = Math.floor(Math.log(absI) / Math.log(10)) + 1;
var found = false,
subtract = 0;
while (numberOfDigits > 0) {
var x = Math.pow(10, --numberOfDigits);
var currentDigit = Math.floor((absI - subtract) / x);
@keune
keune / turkce_isimler.sql
Created July 15, 2012 19:41 — forked from ismailbaskin/turkce_isimler.sql
Türkçe isim veritabanı
-- Turkce isimler sozlugu twitter : http://twitter.com/tserpico
CREATE TABLE `isimler` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`isimler` varchar(255) DEFAULT NULL,
`cinsiyet` varchar(255) DEFAULT NULL COMMENT 'erkek : E , kadın : K , uniseks : U',
PRIMARY KEY (`id`)
) ENGINE=InnoDB;
-- ----------------------------