Skip to content

Instantly share code, notes, and snippets.

Game steps:
* When the game starts, the player gets prompted for the grid size (width x height) and the number of mines.
* The grid is generated according to these requirements.
* The games starts, the user is prompted for the coordinates (x, y) of the first cell to uncover.
* The game shows the resulting grid and prompts for new coordinates.
* And so on ...
The game ends when there is no more non-mined cell to uncover or the player uncovers a mine.
Rules:
@pedrobachiega
pedrobachiega / gist:4117593
Created November 20, 2012 12:14
Reading and parsing GA Cookie UTMZ
cookie_ga_utmz = cookies['__utmz']
source, medium, campaign, value = nil
splited = cookie_ga_utmz.split("|")
splited.each do |token|
if token.include?("utmcsr=")
source = URI.unescape(token.split("utmcsr=")[1])
elsif token.include?("utmcmd=")
medium = URI.unescape(token.split("utmcmd=")[1])
elsif token.include?("utmccn=")
@brettcvz
brettcvz / messenger.js
Created March 20, 2015 02:40
JS-Applescript to send iMessages
#!/usr/bin/env osascript -l JavaScript
function run(argv) {
var to = argv[0];
var msg = argv[1];
console.log("Sending message", "'" + msg + "'", "to", to);
messages = Application('Messages');
var service;
for (var i in messages.services) {
@MattFaus
MattFaus / serverside_appcfg.py
Created November 2, 2013 04:22
A way to programmatically list the versions deployed to a Google AppEngine application by impersonating an RPC from appcfg.py to Google's management servers, using an oauth2 token from an administrator of the application.
# Here's how I got this to work:
# 1. Download this client library into your GAE project:
# https://developers.google.com/api-client-library/python/start/installation#appengine
# https://code.google.com/p/google-api-python-client/downloads/detail?name=google-api-python-client-gae-1.2.zip&can=2&q=
# 2. Copy this file from the GAE SDK installed on your development machine
# google/appengine/tools/appengine_rpc_httplib2.py
# 3. Modify the import statements as necessary
# 4. Create a secrets.py file that defines a appcfg_refresh_token property
# 5. Obtain the refresh token by
# Calling appcfg.py list_versions . --oauth2, this will open a browser so you can login with your Google Account
@hernanliendo
hernanliendo / GCSBackupFileReader.java
Created December 28, 2013 02:33
GCS Backup File Reader Example
package com.zupcat.sca.initializer;
import com.google.appengine.api.datastore.Entity;
import com.google.appengine.api.datastore.EntityTranslator;
import com.google.appengine.api.files.*;
import com.google.appengine.tools.development.testing.LocalBlobstoreServiceTestConfig;
import com.google.appengine.tools.development.testing.LocalDatastoreServiceTestConfig;
import com.google.appengine.tools.development.testing.LocalMemcacheServiceTestConfig;
import com.google.appengine.tools.development.testing.LocalServiceTestHelper;
@max-mapper
max-mapper / readme.md
Created September 28, 2011 02:01
SLEEP - syncable.org

Your API does REST, but can it SLEEP?

SLEEP (Syncable Lightweight Event Emitting Persistence) is an emerging standard for distributed data sync using HTTP and JSON. A generalized version of CouchDB's much lauded built-in replication, SLEEP extends the REST architecture to define a way in which databases can offer syncable JSON APIs that foster open data innovation by allowing developers to replicate entire databases over the net.


SLEEP comes from the Apache CouchDB project which is now widely known for it's multi-master streaming HTTP + JSON replication. This is possible in part because of the CouchDB _changes feed, which is a particular API that lets you see if there have been any changes made to the database since last time you synchronized. CouchDB can efficiently implement the _changes feed because of one subtle difference between it and most other databases: it stores a history of all changes that happen to the database, including deletes.

If you synchronize data from a remote source and then the

@ishikawa
ishikawa / AbstractSubsetsGenerator.java
Created November 2, 2008 15:17
Constructing All Subsets - Backtracking | The Algorithm Design Manual
package backtracking_subsets;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
@riccardoscalco
riccardoscalco / README.md
Last active April 1, 2020 14:02
Topojson of Italy (province)
@markrickert
markrickert / giratchive.sh
Created June 12, 2012 20:20
Git Archive Bash Script
#!/bin/bash
# Takes one parameter: a remote git repository URL.
#
# This is the stuff this script does:
#
# 1. Clones the repository
# 2. Fetches all remote branches
# 3. Compresses the folder
# 4. Deletes the cloned folder.
@mattbaggott
mattbaggott / predicting_customer_behav_1.R
Last active September 15, 2020 22:16
Uses the BTYD package and Pareto/NBD model to predict customer behavior in R Slides are at: http://www.slideshare.net/mattbagg/baggott-predict-customerinrpart1#
#
# PREDICTING LONG TERM CUSTOMER VALUE WITH BTYD PACKAGE
# Pareto/NBD (negative binomial distribution) modeling of
# repeat-buying behavior in a noncontractual setting
#
# Matthew Baggott, matt@baggott.net
#
# Accompanying slides at:
# http://www.slideshare.net/mattbagg/baggott-predict-customerinrpart1#
#