Skip to content

Instantly share code, notes, and snippets.

@kopiro
kopiro / generate-rand-string.sh
Created August 1, 2011 23:27
Generate random string in Bash
#!/bin/sh
head /dev/urandom | uuencode -m - | sed -n 2p | cut -c1-${1:-8};
@kopiro
kopiro / get-gist-snippets-jquery.js
Created August 2, 2011 13:03
Get the GIST snippets (syntax-highlited) with jQuery
var snippets = [];
function loadSnippets() {
snippetsdiv = $("#snippets-feed");
$.ajax({
url: "http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=10&callback=?&q="+encodeURIComponent("https://gist.github.com/kopiro.atom"),
dataType: "json",
success: function (data) {
snippets = data.responseData.feed.entries;
$.each(snippets, function(k,v) {
$.getJSON(v.link+".json?callback=?", function(j){
@kopiro
kopiro / instantsearch-tutorial-index.htm
Created August 4, 2011 08:50
Instant Search Tutorial - index.htm
<!doctype html>
<html>
<head>
<script src="jquery.js"></script>
<script src="script.js"></script>
</head>
<body>
<input type="text" id="q" onkeyup="ajax_search(this.value)" />
<div id="r"></div>
</body>
@kopiro
kopiro / instantsearch-tutorial-script.js
Created August 4, 2011 08:52
Instant Search Tutorial - script.js
ajax_search = function(query) {
jQuery.get("ajax.php", {q:query}, function(html_resp){
$("#r").html(html_resp);
});
}
@kopiro
kopiro / instantsearch-tutorial-ajax.php
Created August 4, 2011 08:54
Instant Search Tutorial - ajax.php
<?php
$q = $_GET["q"];
if ($handle = opendir("."))
while ($file = readdir($handle))
if (is_file($file) && preg_match("/$q/i", $file))
echo "$file <br />";
closedir($handle);
?>
@kopiro
kopiro / rand-htmlcolor.js
Created August 6, 2011 12:04
Random HTML Color in Javascript
randHTMLColor = function () { return "#"+(Math.floor(Math.random()*16777215)).toString(16); }
@kopiro
kopiro / php-downmod-security-fix.php
Created August 7, 2011 16:37
Protect PHP download modules
<?php
$u = $_GET["file"];
$u = realpath($u);
$safedir = realpath("./music/");
if (substr($u, 0, strlen($safedir))!=$safedir) die("Error");
?>
@kopiro
kopiro / steifscript-v1.4-enc.js
Created August 11, 2011 13:45
Steifscript v1.4 (enc)
// OE Version
javascript:eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('l{6(m["7"]){8 0=o.p(q,9,r,b,s,t,u,v,b,w,9,x,y,z,A,B);8 3=C("D E "+0+" c d.\\F e G H I 2 J K L f.\\n\\M N g 2 5 2 O P:","");6(3){3+="\\n[Q R "+0+" c d]";7.S().T(U(a){V.W("X g 2 "+a+"..");h Y().Z("/10/11/5.12").13({14:(h 15().i())+":"+(16()+1),17:18.i(),2:a,19:3}).5()});4(0+" 1a.")}j 4("1b 1c!")}j 4("f 1d e 1e.")}1f(k){4(0+" 1g 1h:\\n"+k)}',62,80,'_ssname||to|_sstext|alert|send|if|AvailableList|var|116||105|by|Kopiro|not|Facebook|message|new|getTime|else|ex|try|window||String|fromCharCode|83|101|102|115|99|114|112|32|118|49|46|52|prompt|Welcome|in|nDo|use|this|script|make|spam|on|nInsert|the|online|users|sent|using|getAvailableIDs|forEach|function|console|log|Sending
@kopiro
kopiro / lastfm-api-example.js
Created August 12, 2011 12:08
Get some information from Last.FM
function loadLastFmSong() {
$.getJSON("http://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&user=destefanoflavio&api_key=b25b959554ed76058ac220b7b2e0a026&format=json&callback=?", function(json) {
lastfmtrack = json.recenttracks.track[0];
$("#lastfm_song").html('<a target="_blank" href="'+lastfmtrack.url+'">'+lastfmtrack.name+", di "+lastfmtrack.artist["#text"]+'</a>');
$("#lastfm_song").append('<img src="http://icons.iconarchive.com/icons/fatcow/farm-fresh/16/music-icon.png" style="margin-left: 4px"/>');
});
}
function loadLastFmArtists(n) {
@kopiro
kopiro / commandrepeat.scpt
Created August 14, 2011 11:40
Command-Repat in Apple Script
tell application "VLC"
activate
repeat 10 times
tell application "System Events" to keystroke "t" using command down
end repeat
end tell