Skip to content

Instantly share code, notes, and snippets.

View evandrix's full-sized avatar
💭
offline

evandrix evandrix

💭
offline
View GitHub Profile
@zeekay
zeekay / errorhandling.go
Last active August 29, 2015 13:55
Go error handling using switch statement to "pattern match" against return value(s) of function.
package main
import "fmt"
// Error
type notSquared struct {
number int
}
func (e notSquared) Error() string {
@mkaufmann
mkaufmann / gist:8716922
Created January 30, 2014 19:30
Stripe-CTF3 Solutions Level -3
Diff for Level0, read file into HashSet:
========================================
+require 'set'
path = ARGV.length > 0 ? ARGV[0] : '/usr/share/dict/words'
-entries = File.read(path).split("\n")
+entries = Set.new File.read(path).split("\n")
override def query(q: String) = {
val responses: Seq[Future[HttpResponse]] = clients.map {client => client.query(q)}
val allResponses: Future[Seq[HttpResponse]] = Future.collect(responses)
val successResponses: Future[Seq[HttpResponse]] = allResponses.map(responses => responses.filter(_.getStatus == HttpResponseStatus.OK))
successResponses.map { responses: Seq[HttpResponse] =>
if (responses.isEmpty) {
errorResponse(HttpResponseStatus.INTERNAL_SERVER_ERROR, "No successful responses")
override def query(q: String) = {
import net.liftweb.json._
import net.liftweb.json.JsonDSL._
import net.liftweb.json.Serialization.{read, write}
implicit val formats = DefaultFormats
val futures = clients.map(_.query(q).map(hr => {
val list = (parse(hr.getContent.toString("UTF-8")) \ "results").children
list.map(_.extract[String])
}))
/* ==========================================================================
Chrome Frame prompt */
/* ========================================================================== */
.chromeframe {
margin: 0;
background: #f7f3d6;
color: #2c2c2c;
font: normal 1em/1.3 Arial, sans-serif;
#coding: utf-8
from cStringIO import StringIO
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.header import Header
from email import Charset
from email.generator import Generator
import smtplib
# Example address data
@jairsaidds
jairsaidds / gist:9540889
Created March 14, 2014 02:03
MAXIMAL SUBSET OF ARRAY
#include <algorithm>
#include <math.h>
#include <numeric>
#include <iostream>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <cstring>
#define lli long long int
@wblakecaldwell
wblakecaldwell / google_io_puzzle.py
Last active August 29, 2015 14:00
Google I/O secret invite code finder
#
# Google I/O 2014 secret invite code finder
#
# Blake Caldwell, 2014
#
# Blog Post: http://blakecaldwell.net/blog/2014/4/23/solving-a-2014-google-io-secret-invite-puzzle.html
#
# Repeatedly hit https://developers.google.com looking two-colored "I/O" on the page,
# with a secret code in comments below it. Using the color codes of the "I" and "O",
# calculate the 6-character Google URL-shortened link code, and print the code out.
@autekroy
autekroy / Google Code Jam Round 1B 2014 - Problem A.The Repeater (small input).cpp
Created May 4, 2014 07:29
Google Code Jam Round 1B 2014 - Problem A.The Repeater (small input)
//Google Code Jam Round 1B 2014 - Problem A.The Repeater (small input)
//https://code.google.com/codejam
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<iostream>
using namespace std;
int findAns(char* str1, char* str2, int len1, int len2)
@kusano
kusano / UpandDown.py
Created May 31, 2014 16:33
Google Code Jam 2014 Round 2 B Up and Down
for test in range(input()):
N = input()
A = map(int, raw_input().split())
ans = 0
for i in range(N):
l = 0
r = 0
for j in range(N):
if A[j]>A[i]:
if j<i: