This file contains 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 | |
import sys | |
import getopt | |
import boto | |
from datetime import datetime | |
from dateutil.tz import tzoffset | |
from dateutil.parser import parse as parse_date | |
from time import strftime |
This file contains 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
find ./ -type f | grep -E ".*\.[a-zA-Z0-9]*$" | sed -e 's/.*\(\.[a-zA-Z0-9]*\)$/\1/' | sort | uniq -c | sort -rn |
This file contains 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
for (var key in obj) { | |
if (obj.hasOwnProperty(key)) { | |
console.log(key + " -> " + obj[key]); | |
} | |
} |
This file contains 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 | |
// sort 'inventory' array by 2nd level value 'price' | |
$price = array(); | |
foreach ($inventory as $key => $row) | |
{ | |
$price[$key] = $row['price']; | |
} | |
array_multisort($price, SORT_DESC, $inventory); |
This file contains 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').on('click', 'a.myclass', function() { | |
// do something | |
}); |
This file contains 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
git checkout c5f567 -- file1/to/restore file2/to/restore |
This file contains 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
package main | |
import ( | |
"encoding/json" | |
"flag" | |
"fmt" | |
"io/ioutil" | |
"log" | |
"net/http" | |
"net/url" |
This file contains 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 | |
$flat = [ 'this', 'seems', 'a', 'bit', 'strange']; | |
$nested = []; | |
function v2h_array(&$flat, &$nested) { | |
$nested[$flat[0]] = []; | |
while (count($flat) > 1) { | |
v2h_array(array_splice($flat, 1, count($flat)-1), $nested[$flat[0]]); | |
} |
This file contains 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 delete_attachments_without_author() | |
{ | |
foreach (get_posts(['post_type' => 'attachment', 'posts_per_page' => -1]) as $att) { | |
if (!$att->post_author) { | |
wp_delete_post($att->ID, true); | |
} | |
} | |
} |