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
// Demo for connecting to Bonsai.io using the Elasticsearch client for Go. | |
// Make sure to match your Bonsai cluster version to the Go client version. | |
// Validated using a Bonsai cluster running Elasticsearch 6.2.3. | |
// | |
// 1. go get github.com/olivere/elastic | |
// 2. go build bonsai.go | |
// 3. ./bonsai | |
// 4. Program will create an index called `test` on your Bonsai cluster. | |
// | |
// Feel free to tweak/clean up as needed, golang isn't my specialty. |
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
// Advent of Code 2016: Day 1 | |
// http://adventofcode.com/2016/day/1 | |
// Data structure representing the elf navigating the city. | |
struct Elf { | |
x: i32, | |
y: i32, | |
heading: f32, | |
positions: Vec<(i32,i32)>, | |
revisit: bool |
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
#!/bin/bash | |
# Simple shell script for downloading audio from YouTube as .mp3 file | |
# Requires: | |
# * youtube-dl (http://rg3.github.io/youtube-dl/) | |
# * id3tag (Ubuntu libid3 package, based on http://id3lib.sourceforge.net/) | |
if [ -z "$1" ]; then | |
echo "Usage: yt2mp3 <file>" | |
echo "File supplied must have a list of URLs to YouTube videos and ID3" | |
echo "information, comma-separated." |
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 program simulates a number of games involving | |
// The Monty Hall Problem, and compares two approaches: | |
// sticking with the player's original choice, or | |
// switching to the other option. The program measures | |
// how successful each approach is and prints the | |
// result to the screen. I used PHP since it is easy to | |
// read and understand, but this program could easily | |
// be ported to any number of other languages. |
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
#!/bin/bash | |
# This code should not be run as `sh find_all_modules.sh`, as some distros | |
# link sh to dash, which is POSIX-compliant and doesn't do arrays. | |
# Adapted from Linux Kernel in a Nutshell: http://www.kroah.com/lkn/ | |
# By Rob Sears, Sept 22, 2013. | |
# Get a newline-separated list of modules in use: | |
MODLIST=`for i in $(find /sys/ -name modalias -exec cat {} \; 2>/dev/null); do /sbin/modprobe --config /dev/null --show-depends $i 2> /dev/null;done | rev | cut -f 1 -d '/' | rev | sort -u` | |
# Convert the newline-separated list to an array: |
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 | |
// A quick and dirty script for bulk importing MySQL data into a Solr index | |
// Edit this array with the MySQL fields that will be sent to the SOLR index | |
// The key is the name of the MySQL column and the value is its respective Solr field | |
// | |
// Example: 'mysql_col_name' => 'solr_field' | |
// | |
$field_mappings = array( | |
'id' => 'id', |
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
# Given: a lat/lng coordinate | |
# Return: the tile and pixel coordinates of given position | |
# By Rob Sears, Feb 2013 | |
import math | |
GPS_Lat = 37.364101 # A neat little SR-71 | |
GPS_Lng = -120.577612 # Blackbird in California | |
zoom = 21 | |
n = math.pow(2, zoom) |
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
/* | |
* hworld.cpp | |
* http://www.wxwidgets.org/docs/tutorials/hworld.txt | |
*/ | |
#include <wx\wx.h> | |
class MyApp: public wxApp | |
{ | |
virtual bool OnInit(); |
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
# Adapted from http://www.aishack.in/2010/07/transparent-image-overlays-in-opencv/ | |
import wx | |
from cv2 import * | |
capture = cv.CaptureFromCAM(0) | |
overlay = cv.LoadImage("ghost.png") | |
posx = 0 | |
posy = 0 | |
xdir = 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
# Adapted from http://www.aishack.in/2010/07/transparent-image-overlays-in-opencv/ | |
# Note: This code assumes a PNG with a Color->Transparency, with black as the alpha color | |
from cv2 import * | |
src = cv.LoadImage("image.jpg") # Load a source image | |
overlay = cv.LoadImage("ghost.png") # Load an image to overlay | |
posx = 170 # Define a point (posx, posy) on the source | |
posy = 100 # image where the overlay will be placed | |
S = (0.5, 0.5, 0.5, 0.5) # Define blending coefficients S and D |
NewerOlder