Skip to content

Instantly share code, notes, and snippets.

View hasantayyar's full-sized avatar
⌨️
AFK

Hasan Tayyar Beşik hasantayyar

⌨️
AFK
View GitHub Profile
static String decodeCp1251(byte[] data)
{
if (data == null)
{
throw new IllegalArgumentException("Null argument");
}
StringBuffer sb = new StringBuffer(data.length);
for (int i = 0; i < data.length; i++)
{
sb.append(cp1251Map[data[i] & 0xFF]);
@hasantayyar
hasantayyar / 500px-com.js
Created August 24, 2011 06:36
500px.com append image and allow save as
$("body").append("<img src="+$("#photo img").attr("src")+" />");
@hasantayyar
hasantayyar / getYoutubeThumbnail.php
Created October 4, 2011 13:07
Youtube get thumnail from url
<?php
function getThumb($url, $size="big") {
$size = (size === null) ? "big" : $size;
$p = "/([\\?&])v=([^&#]*)/i";
// you can use parse_str to get video id
if(preg_match($p,$url,$results)){
$vid = $results[2];
if (size == "small") {
return "http://img.youtube.com/vi/" . $vid . "/2.jpg";
} else {
import urllib
def fetch_thing(url, params, method):
params = urllib.urlencode(params)
if method=='POST':
f = urllib.urlopen(url, params)
else:
f = urllib.urlopen(url+'?'+params)
return (f.read(), f.code)
for x in range(0,30):
content, response_code = fetch_thing(
@hasantayyar
hasantayyar / ffmpeg_cut.sh
Created October 21, 2011 05:28
ffmpeg cut
ffmpeg -ss 00:01:20 -t 00:01:50 -i file.mp3 -acodec copy cutted.mp3
@hasantayyar
hasantayyar / bcrypt.php
Created October 23, 2011 00:25
sample Bcrypt class for php
<?php
/*
*
// seen on
// http://stackoverflow.com/questions/4795385/how-do-you-use-bcrypt-for-hashing-passwords-in-php/6337021#6337021
// usage
$bcrypt = new Bcrypt(15);
$hash = $bcrypt->hash('password');
@hasantayyar
hasantayyar / thepiratebay-search.sh
Created October 27, 2011 06:54
thepiratebay search with bash
# seean on http://www.commandlinefu.com/commands/view/9581/thepiratebay.org-torrent-search
# usage :
# tpb search
tpb() { wget -U Mozilla -qO - $(echo "http://thepiratebay.org/search/$@/0/7/0" | sed 's/ /\%20/g') | grep -o 'http\:\/\/torrents\.thepiratebay\.org\/.*\.torrent' | tac; }
@hasantayyar
hasantayyar / browser.js
Created November 1, 2011 10:33
javascript browser detection functions
// seen in pinterest bookmarklet
function isIE() {
return /msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent)
}
function isSafari() {
return /Safari/.test(navigator.userAgent) && !/Chrome/.test(navigator.userAgent)
}
function isIOS() {
return navigator.userAgent.match(/iPad/i) != null || navigator.userAgent.match(/iPhone/i) != null || navigator.userAgent.match(/iPod/i) != null || navigator.userAgent.match(/iPod/i) != null
}
@hasantayyar
hasantayyar / isimler.sql
Created December 10, 2011 15:13 — forked from ismailbaskin/turkce_isimler.sql
isim sözlüğü
CREATE TABLE `isimler` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`ad` varchar(255) COLLATE utf8_bin NOT NULL,
`cinsiyet` varchar(50) COLLATE utf8_bin NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `ad` (`ad`),
KEY `cinsiyet` (`cinsiyet`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
@hasantayyar
hasantayyar / blogla.js
Created December 10, 2011 18:10
Blogcu.com blogbla bookmarklet
javascript:void((function(){var el=document.getElementById('_blogcu_genel');if(el!=null){Bel.parentNode.removeChild(el);}var e=document.createElement('script');e.setAttribute('type','text/javascript');e.setAttribute('charset','UTF-8');e.setAttribute('src', 'http://www.blogcu.com/bookmarklet/bookmarklet.js?'+Math.floor(Math.random()*999999));document.body.appendChild(e)})());