Skip to content

Instantly share code, notes, and snippets.


Crisoforo Gaspar Hernández mitogh

Block or report user

Report or block mitogh

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
mitogh / functions.php
Last active Sep 19, 2017
Upload assets to Wordpress
View functions.php
function upload_asset( $location, $post_id ) {
$timeout_seconds = MINUTE_IN_SECONDS * 10;
$tmp_file = download_url( $location, $timeout_seconds );
if ( is_wp_error( $tmp_file ) ) {
@unlink( $tmp_file );
return false;
$type = wp_check_filetype( $tmp_file );
mitogh / states.txt
Last active Jan 23, 2016
US States
View states.txt
AL : Alabama
AK : Alaska
AZ : Arizona
AR : Arkansas
CA : California
CO : Colorado
CT : Connecticut
DE : Delaware
FL : Florida
GA : Georgia
View gist:b07ec1febcac9007f95e
Interesting Javascript puzzle (from a recent programming contest):
How do you create a number 100000000000000000000 in Javascript using only these four characters: '+', '!', '[', ']' and you can only use at most 60 such characters?
Some hints:
+!![] is equal to number 1
+!![]+!![] is equal to number 2
(don't answer if you participated in that contest)
FYI, the answer is super tricky and close to "cheating".
mitogh /
Last active Aug 29, 2015
Clean the history of your downloads, (MAC)
# Show all the current LOG of your history.
sqlite3 ~/Library/Preferences/* 'select LSQuarantineDataURLString from LSQuarantineEvent'
# Delete all the entries from the history.
sqlite3 ~/Library/Preferences/* 'delete from LSQuarantineEvent'
# Credits:
mitogh /
Created Sep 19, 2014
Change default location for the screenshots in Mac
defaults write location ~/Pictures
killall SystemUIServer
# Where ~/Pictures is the current location where the screenshots
# are going to be saved.
mitogh /
Created Sep 19, 2014
Change format of the screenshots in Mac.
defaults write type png
killall SystemUIServer
# Different formats
# png: Portable Network Graphic
# pdf: Portable Document Format
# jpg: Joint Photographic Experts Group (JPEG)
# tif: Tagged Image File Format (TIFF)
# gif: Graphics Interchange Format
# pct: Macintosh QuickDraw Picture (PICT)
You can’t perform that action at this time.