Skip to content

Instantly share code, notes, and snippets.

@ianbarber
ianbarber / RetrieveAccessTokenActivity.java
Created March 17, 2014 20:22
A quick example of retrieving an access token with GoogleAuthUtil
package com.google.devrel.samples.gmstest.app;
import android.app.Activity;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
@nicolashery
nicolashery / elasticsearch.md
Last active December 30, 2023 19:03
Elasticsearch: updating the mappings and settings of an existing index

Elasticsearch: updating the mappings and settings of an existing index

Note: This was written using elasticsearch 0.9.

Elasticsearch will automatically create an index (with basic settings and mappings) for you if you post a first document:

$ curl -X POST 'http://localhost:9200/thegame/weapons/1' -d \
'{
  "_id": 1,
@christianroman
christianroman / test.py
Created May 30, 2013 16:02
Bypass Captcha using 10 lines of code with Python, OpenCV & Tesseract OCR engine
import cv2.cv as cv
import tesseract
gray = cv.LoadImage('captcha.jpeg', cv.CV_LOAD_IMAGE_GRAYSCALE)
cv.Threshold(gray, gray, 231, 255, cv.CV_THRESH_BINARY)
api = tesseract.TessBaseAPI()
api.Init(".","eng",tesseract.OEM_DEFAULT)
api.SetVariable("tessedit_char_whitelist", "0123456789abcdefghijklmnopqrstuvwxyz")
api.SetPageSegMode(tesseract.PSM_SINGLE_WORD)
tesseract.SetCvImage(gray,api)
print api.GetUTF8Text()
@klmr
klmr / auto_cast.hpp
Last active December 16, 2015 09:28
template <typename Source>
struct auto_cast_helper {
Source const& value;
explicit auto_cast_helper(Source const& value) : value(value) { }
template <typename Target>
operator Target() const {
return static_cast<Target>(value);
}
@briandoll
briandoll / A_toast_to_you.md
Last active March 19, 2022 01:17
Toasts! - scripts to convert images attached to GitHub issues into an animated gif for serious celebratory purposes

To toast:

  • Make sure you have ImageMagick installed (brew install imagemagick)
  • Change line 7 of toast.rb to the repository name you're working with
  • toast!
$ bundle install
$ ./get_token [user] [pass]
$ export GHUSER=[myuser]
@klmr
klmr / gist:4250731
Created December 10, 2012 14:04
C++11 enum classes boilerplate
enum class dna_strand : char {
positive = '+',
negative = '-'
};
std::ostream& operator <<(std::ostream& out, dna_strand strand) {
return out << static_cast<char>(strand);
}
std::istream& operator >>(std::istream& in, dna_strand& strand) {
@nicdaCosta
nicdaCosta / Grep.js
Last active March 9, 2024 13:39
Basic function that searches / filters any object or function and returns matched properties.
/*
Grep.js
Author : Nic da Costa ( @nic_daCosta )
Created : 2012/11/14
Version : 0.2
(c) Nic da Costa
License : MIT, GPL licenses
Overview:
Basic function that searches / filters any object or function and returns matched properties.
@klmr
klmr / string.hpp
Created October 12, 2012 17:21
Ultra-simple string class
#ifndef TEXT_STRING_HPP
#define TEXT_STRING_HPP
#include <algorithm>
#include <cstring>
#include <iterator>
#include <memory>
#include <iosfwd>
namespace text {
@juandopazo
juandopazo / result.js
Created October 6, 2012 17:33
YUI TypeScript definitions
module Y {
interface Anim extends Base {
}
interface App extends App_Base, App_Content, App_Transitions, PjaxContent {
(config?: any);
@chrisguitarguy
chrisguitarguy / checker.go
Created September 8, 2012 22:52
A simple URL status checker in Go. Made to practice a bit with channels and goroutines.
package main
import (
"bufio"
"container/list"
"flag"
"fmt"
"net/http"
"io"
"os"