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 | |
/** | |
* This curl function might be useful when get_file_contents() cannot be used for any reasons. | |
* E.g. when you need to pass user agent etc. | |
* | |
* Todo: return array with response code & the content | |
*/ | |
function get_curl_output_by_url ( $_curl_url ) { | |
$ch = curl_init(); | |
$useragent="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1"; |
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
I wanted to analyse this function for my use. ... I want to make a javascript function (for gruntjs) to get version number oftheme. | |
/** | |
* Retrieve metadata from a file. | |
* | |
* Searches for metadata in the first 8kiB of a file, such as a plugin or theme. | |
* Each piece of metadata must be on its own line. Fields can not span multiple | |
* lines, the value will get cut at the end of the first line. | |
* | |
* If the file data is not within that first 8kiB, then the author should correct |
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
/* | |
* Calculates the Twitter time since the tweet was created | |
* Based on http://www.jquery4u.com/api-calls/calculate-twitter-time-tweet-javascript/ | |
* @param obj with datetime (e.g. git time etc). and limitSwitch (optional) in minute --- any dates beyond that will be in date in string | |
* @return time since in html | |
*/ | |
var calculateSince = function ( _parameter ) { | |
var _datetime = _parameter.dateTime.replace(/\-/g,'/'); | |
var _limitSwitch = (_parameter.limitSwitch) ? _parameter.limitSwitch : 4320; /* optional */ |
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
In terminal: | |
If you have a new local github repo without any file added, do: | |
$ jekyll new ./ | |
It installs all the default jekyll files in the directory. | |
To launch a local server: |
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
/* | |
copy and paste into the console of browser | |
*/ | |
var _listArray = []; | |
jQuery('tbody tr[role=row]').each(function (i) { | |
var $_current = $(this); | |
var _name = $_current.find(':nth-child(1) a').text(); | |
var _email = $_current.find(':nth-child(2) a').text(); | |
_listArray.push({ | |
name: _name, |
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/env bash | |
# requires geoiplookup, do "brew install geoip" | |
# and brew install geoiplookup | |
# this is how to extract ip addresses and the count of occurances | |
# egrep -o '[0-9]+(\.[0-9]+){3}' < accesslog.txt | sort | uniq -c | sort -nr > access.txt | |
# specify the output access.txt as an argument, | |
if [ $# -ne 1 ]; then | |
echo "$# argument specified" 1>&2 | |
echo "this script requires 1 argument" 1>&2 | |
exit 1 |
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 | |
// for example, in your functions.php or anywhere in your theme | |
// Use wp_loaded action hook | |
add_action( 'wp_loaded', 'get_my_options' ); | |
function get_my_options() { | |
define('MY_OPTION',get_theme_mod('my_option', FALSE)); | |
} |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Document</title> | |
</head> | |
<body> | |
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod | |
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, | |
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Document</title> | |
</head> | |
<body> | |
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod | |
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, | |
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo |
OlderNewer