Skip to content

Instantly share code, notes, and snippets.

:bowtie:

Crisoforo Gaspar Hernández mitogh

:bowtie:
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
mitogh / functions.php
Last active Sep 19, 2017
Upload assets to Wordpress
View functions.php
<?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
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
mitogh / clearHistory.sh
Last active Aug 29, 2015
Clean the history of your downloads, (MAC)
View clearHistory.sh
#!/bin/bash
# Show all the current LOG of your history.
sqlite3 ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV* 'select LSQuarantineDataURLString from LSQuarantineEvent'
# Delete all the entries from the history.
sqlite3 ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV* 'delete from LSQuarantineEvent'
# Credits:
# http://lifehacker.com/your-mac-logs-everything-you-download-heres-how-to-cle-1658394180
@mitogh
mitogh / changeLocationScreenshots.sh
Created Sep 19, 2014
Change default location for the screenshots in Mac
View changeLocationScreenshots.sh
defaults write com.apple.screencapture location ~/Pictures
killall SystemUIServer
# Where ~/Pictures is the current location where the screenshots
# are going to be saved.
@mitogh
mitogh / changeFormatScreenshot.sh
Created Sep 19, 2014
Change format of the screenshots in Mac.
View changeFormatScreenshot.sh
defaults write com.apple.screencapture 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.