Skip to content

Instantly share code, notes, and snippets.

Hasan Tayyar BEŞİK hasantayyar

View GitHub Profile
View decodeCp1251.java
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 Aug 24, 2011
500px.com append image and allow save as
View 500px-com.js
$("body").append("<img src="+$("#photo img").attr("src")+" />");
@hasantayyar
hasantayyar / getYoutubeThumbnail.php
Created Oct 4, 2011
Youtube get thumnail from url
View getYoutubeThumbnail.php
<?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 {
View (test)kimdircom-stat-fuzzer.py
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(
View ffmpeg_cut.sh
ffmpeg -ss 00:01:20 -t 00:01:50 -i file.mp3 -acodec copy cutted.mp3
@hasantayyar
hasantayyar / bcrypt.php
Created Oct 23, 2011
sample Bcrypt class for php
View bcrypt.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 Oct 27, 2011
thepiratebay search with bash
View thepiratebay-search.sh
# 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 Nov 1, 2011
javascript browser detection functions
View browser.js
// 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
}
View isimler.sql
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 Dec 10, 2011
Blogcu.com blogbla bookmarklet
View blogla.js
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)})());
You can’t perform that action at this time.