This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('body').append('<div id="dllinks"></div>'); | |
pad = "000"; | |
dllinks = $('#dllinks'); | |
$('ul.course-item-list-section-list li').each(function(index){ | |
str = "" + index; | |
padindex = pad.substring(0, pad.length - str.length) + str + ' '; | |
text = $(this).find('a.lecture-link').text(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
ls -1 | sort -R | head -n1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Author: Dusko Petrovic <[email protected]> | |
# | |
# | |
# Usage: | |
# ./wordcombinator.sh WORD OVERLAPCHARS OVERLAPEND | |
# WORD - word you are looking to combine with something | |
# OVERLAPCHARS - number of characters to combine - default 2 | |
# OVERLAPEND - 1 - overlap characters from the end - default |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var list = []; | |
$('#main_table_blue tbody tr').each(function(){ | |
countryName = $(this).find('td:first-child a').text(); | |
countryCode = $(this).find('td:nth-child(3)').text(); | |
list.push('+'+countryCode+' '+countryName); | |
}); | |
$('body').append('<div id="countrycodes"></div>"'); | |
$('#countrycodes').append(list.join('<br />')); | |
console.debug(list); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getPageContent(page_type){ | |
if (page_type == 'page'){ | |
if ($('.page:not(body)').length) | |
return $('.page:not(body)'); | |
} | |
else if (page_type == 'post'){ | |
if ($('.post:not(body)').length) | |
return $('.post:not(body)'); | |
else if ($('article').length) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
php -r '$img = imagecreatefromjpeg($argv[1]); $rotate = imagerotate($img, 180, 0); imagejpeg($rotate, basename($argv[1],".jpg")."_rotated.jpg");' my_image.jpg |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
If you are writing shell scripts that manipulate big amounts of data it is helpful to the person running the script to know what is going on. | |
The easies way is to just print out a status line every now and then. The problem is when we have a lot of status updates with just a small change we end up with a full screen of status updates but with very little useful data. | |
For example, we have a list of cities that we are updating and we would like to know how far along are we. | |
We could print a bunch of lines like this | |
Updating cities: loaded 10000 | |
Updating cities: loaded 20000 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('<div id="JQUERY_URL_LIST"></div>').appendTo('body'); | |
var texts = ["SD","HD","click here"]; | |
var extensions = ['pdf','mp3','m4a','m4v','zip','jpg','png','gif']; | |
var getLinksByText = function(texts){ | |
for(t in texts){ | |
var text = texts[t]; | |
$('a:contains("'+text+'")').each(function(){ | |
var url = $(this).attr('href')+'</br>'; | |
$('#JQUERY_URL_LIST').append(url); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import os, zipfile | |
for filename in os.listdir("."): | |
if filename.endswith(".zip"): | |
print filename | |
name = os.path.splitext(os.path.basename(filename))[0] | |
if not os.path.isdir(name): | |
try: | |
zip = zipfile.ZipFile(filename) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Symfony\Component\Yaml\Yaml; | |
function flattenKeys($data, $parent = ''){ | |
$result = array(); | |
if (!is_array($data)) { | |
return $result; | |
} | |
foreach ($data as $key => $value) { |
OlderNewer