Skip to content

Instantly share code, notes, and snippets.

@kriskhaira
kriskhaira / checkdns
Created November 28, 2010 16:14
Useful for checking DNS propagation with Google Public DNS and OpenDNS after migrating servers
#!/bin/bash
# checkdns
# A very simple dig tool for checking DNS propagation with Google Public DNS and OpenDNS after migrating servers
#
# INSTRUCTIONS
# Put this in your ~/bin folder, make it executable and run it by typing "checkdns" in your command line
read -p "Enter domain: " domain
# Google Public DNS
function setWeatherIcon(condid) {
switch(condid) {
case '0': var icon = '<i class="wi-tornado"></i>';
break;
case '1': var icon = '<i class="wi-storm-showers"></i>';
break;
case '2': var icon = '<i class="wi-tornado"></i>';
break;
case '3': var icon = '<i class="wi-thunderstorm"></i>';
@protrolium
protrolium / YouTube API — getting video thumbnail
Created February 5, 2014 19:57
YouTube API — getting video thumbnail
Each YouTube video has 4 generated images. They are predictably formatted as follows:
http://img.youtube.com/vi/<insert-youtube-video-id-here>/0.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/1.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/2.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/3.jpg
The first one in the list is a full size image and others are thumbnail images. The default thumbnail image (ie. one of 1.jpg, 2.jpg, 3.jpg) is:
http://img.youtube.com/vi/<insert-youtube-video-id-here>/default.jpg
@trentbrooks
trentbrooks / gist:11392776
Created April 29, 2014 07:18
Download all images from website (1-88 on gratisography.com) with curl
curl "http://www.gratisography.com/pictures/[1-88]H.jpg" -o "#1.jpg"
@mgrigajtis
mgrigajtis / gist:e8cc737ecf405b14bf24
Created May 29, 2014 13:53
Parsing ElasticSearch Results with Java
import java.io.BufferedInputStream;
import java.net.URL;
import java.net.URLConnection;
import org.json.JSONArray;
import org.json.JSONObject;
protected void foo () {
// The input stream from the JSON response
BufferedInputStream buffer = null;
function setWeatherIcon(condid) {
var icon = '';
switch(condid) {
case '0': icon = 'wi-tornado';
break;
case '1': icon = 'wi-storm-showers';
break;
case '2': icon = 'wi-tornado';
break;
case '3': icon = 'wi-thunderstorm';
@scpurcell
scpurcell / Misc.java
Last active February 1, 2023 06:51
Java - using reflection to copy matching fields from one object to another
/**
* Use reflection to shallow copy simple type fields with matching names from one object to another
* @param fromObj the object to copy from
* @param toObj the object to copy to
*/
public static void copyMatchingFields( Object fromObj, Object toObj ) {
if ( fromObj == null || toObj == null )
throw new NullPointerException("Source and destination objects must be non-null");
Class fromClass = fromObj.getClass();
function setWeatherIcon(condid) {
var icon = '';
switch(condid) {
case '0': icon = 'wi-tornado';
break;
case '1': icon = 'wi-storm-showers';
break;
case '2': icon = 'wi-tornado';
break;
case '3': icon = 'wi-thunderstorm';
@guiliredu
guiliredu / facebook-page-invite.js
Last active July 2, 2024 15:12
Facebook - Script to auto invite people who liked a page post do like the page
var buttons;
buttons = document.getElementsByClassName('_42ft');
for (var i = 0; i < buttons.length; i++) {
if(buttons[i].getAttribute('ajaxify') != null){
if(buttons[i].getAttribute('ajaxify').indexOf('invite') != -1){
buttons[i].click();
}
}
}
@rjz
rjz / ngrok_hostname.sh
Created August 9, 2016 16:20
Get ngrok hostname from command line
#!/bin/sh
# ngrok's web interface is HTML, but configuration is bootstrapped as a JSON
# string. We can hack out the forwarded hostname by extracting the next
# `*.ngrok.io` string from the JSON
#
# Brittle as all get out--YMMV. If you're still reading, usage is:
#
# $ ./ngrok_hostname.sh <proto> <addr>
#