Skip to content

Instantly share code, notes, and snippets.

View bxt's full-sized avatar

Bernhard Häussner bxt

View GitHub Profile
// Scraping Made Easy with jQuery and SelectorGadget
// (http://blog.dtrejo.com/scraping-made-easy-with-jquery-and-selectorga)
// by David Trejo
//
// Install node.js and npm:
// http://joyeur.com/2010/12/10/installing-node-and-npm/
// Then run
// npm install jsdom jquery http-agent
// node numresults.js
//
@micho
micho / debug.js
Created February 9, 2012 10:50
debug times for js
/**
* Create a debugger with the given `name`.
*
* @param {String} name
* @return {Type}
* @api public
*/
function debug(name) {
var now = Date.now();
@sbone
sbone / .bashrc
Created February 17, 2012 16:23
Customized .bashrc
# RVM
export PATH="./bin:$PATH"
[[ -s "/Users/Steven/.rvm/scripts/rvm" ]] && source "/Users/Steven/.rvm/scripts/rvm"
# Git command and branch name tab-completion
source ~/git-completion.bash
# Check if directory is a Git repo
# Customized from http://vvv.tobiassjosten.net/git/add-current-git-branch-to-your-bash-prompt
git_prompt ()
@kevinadi
kevinadi / unfoldr.scala
Created May 10, 2016 07:09
unfoldr in Scala
def unfoldr[A, B](seed: B)(func: B => Option[(A, B)]): Stream[A] =
func(seed) match {
case Some((a, b)) => a #:: unfoldr(b)(func)
case None => Stream.empty
}
/*
* Infinite sequence:
* val s = unfoldr (0) (b => Some(b,b+1))
* Fibonacci sequence:
@aloiscochard
aloiscochard / Stream.scala
Created November 2, 2011 16:06
Scala [In]finite Stream Constructor
import Stream._
/** A possibly finite stream that repeatedly applies a given function to a start value.
*
* @param start the start value of the stream
* @param f the function that's repeatedly applied
* @return the stream returning the possibly finite sequence of values `start, f(start), f(f(start)), ...`
*/
def iterate[A](f: A => A, a: A): Stream[A] = unfold((x: A) => Some((x, f(x))), a)
@cschell
cschell / last_game.rb
Last active February 11, 2019 19:19
This script queries the RIOT-API for the last game of a summoner
# Usage: ruby last_game.rb <summoner_name> <na/euw/...>
require "net/http"
require "json"
require "date"
# TODO: Insert your own key here!
API_KEY = "<YOUR-RIOT-API-KEY-HERE>"
@summoner_name = ARGV[0]
@smac89
smac89 / immutable-stack.scala
Last active May 4, 2021 18:28 — forked from lambda-hacker/immutable-stack.scala
Stack using List [Scala]
// Immutable Stack Type using List
case class Stack[A] (elems: Seq[A] = List.empty[A]) {
def push(v: A) : Stack[A] = Stack(v +: elems)
def pushAll(xs: Iterable[A]) : Stack[A] =
xs.foldLeft (this) ((accStack, e) => accStack.push(e))
def pop(): Either[String, (A, Stack[A])] = {
if (isEmpty) Left("Cannot pop from empty stack")
@mbostock
mbostock / .block
Last active October 16, 2021 11:08
Collision Detection
license: gpl-3.0
redirect: https://observablehq.com/@d3/collision-detection/2
@alexjercan
alexjercan / aoc2021-day06.ipynb
Created December 6, 2021 21:38
Aoc2021 day06 lanternfish got out of hand
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@archon810
archon810 / BuildConfig.java
Last active September 28, 2022 15:17
Fake Virus Shield AV
package com.deviant.security.shield;
public final class BuildConfig {
public static final String BUILD_TYPE = "debug";
public static final boolean DEBUG;
public static final String FLAVOR = "";
public static final String PACKAGE_NAME = "com.deviant.security.shield";
public static final int VERSION_CODE = 4;
public static final String VERSION_NAME = "2.2";