Skip to content

Instantly share code, notes, and snippets.

View jonalmeida's full-sized avatar
🦊
making browsers..

Jonathan Almeida jonalmeida

🦊
making browsers..
View GitHub Profile
@jonalmeida
jonalmeida / HashTable.java
Last active August 29, 2015 14:12
Simple hash table in Java with add(), remove() and getElement()
package com.jonalmeida.HashTable;
public class HashTable<T> {
static final int DEFAULT_INITIAL_SIZE = 16;
private Node<T>[] table;
// Create a HashTable with an array size of `initialCapacity`.
public HashTable(int initialCapacity) {
if (initialCapacity < 0) {
throw new IllegalArgumentException("initialCapacity is of a negative number.");
@jonalmeida
jonalmeida / dlist.rs
Last active August 29, 2015 14:14 — forked from pythonesque/dlist.rs
use list::Node;
mod list {
use std::mem;
#[derive(Show)]
pub struct Node<T> {
pub data: T,
prev: Option<Box<Node<T>>>,
next: Option<Box<Node<T>>>
@jonalmeida
jonalmeida / app.js
Created February 13, 2015 22:00
Using pHash on Ron Paul
var pHash = require("phash");
/*
var hashA = pHash.imageHashSync("cat.jpg");
var hashB = pHash.imageHashSync("cat2.jpg");
console.log("Image hash of cat: ", hashA);
console.log("Image hash of cat2: ", hashA);
*/
var hashA = pHash.imageHashSync("ron_paul1.jpg");
var hashB = pHash.imageHashSync("ron_paul2.jpg");
@jonalmeida
jonalmeida / grab_email.py
Created March 12, 2015 01:57
Email grabbing from tab separated list
with open('windsor_bus_list.txt') as fp:
junk = fp.readline()
for line in iter(fp.readline, ''):
print line.split('\t')[2]
fp.close()
{
'submit_timestamp': 1436304039,
'build_system_type': 'taskcluster',
'machine_name': 'unknown',
'job_group_symbol': '?',
'job_group_name': 'unknown',
'platform_option': 'opt',
'job_type_description': 'fill me',
'signature': '3b3bb91e6817188cf0525fccac5be776207f234b',
'result_set_id': 58106,
# HG changeset patch
# User Jonathan Almeida [:jonalmeida] <[email protected]>
# Date 1437523313 25200
# Tue Jul 21 17:01:53 2015 -0700
# Node ID 8f1665e896e598b9f529c6b53943eb01ba0b534b
# Parent a6b93cceaf4e15a45d37cd5e75660cdc7d671b10
Bug 1184211 - Replace TwoWayView in SearchBar with RecyclerView. r?sebastian
diff --git a/mobile/android/base/home/BrowserSearch.java b/mobile/android/base/home/BrowserSearch.java
--- a/mobile/android/base/home/BrowserSearch.java
@jonalmeida
jonalmeida / README.md
Created July 24, 2015 18:11
Notifies you when your try build is complete.

Why

Instead of checking when your try build is complete, this short python script checks try every 5 mins (you can change the interval if you like) using the treeherder API to see if your try push is complete. Gives you a simple notification in your Notification Center (on Mac OS).

How To Use

  • chmod +x try_to_notify
  • (Optional) Move to your /usr/local/bin and remove .py extension
  • try_to_notify [sha_of_the_try_push]

Examples

# Converting markdown to pdf using pandoc; a quick function wrapper
export PATH=/usr/texbin:$PATH
md2pdf() {
pandoc $1 -o `basename $1 .md`.pdf
}
src/lib.rs:25:25: 25:51 error: borrowed value does not live long enough
src/lib.rs:25 let name = Uuid::new_v4().to_string().as_str();
^~~~~~~~~~~~~~~~~~~~~~~~~~
src/lib.rs:24:37: 34:6 note: reference must be valid for the lifetime 'a as defined on the block at 24:36...
src/lib.rs:24 where T: Into<Cow<'a, str>> {
src/lib.rs:25 let name = Uuid::new_v4().to_string().as_str();
src/lib.rs:26 let mut clocks = HashMap::new();
src/lib.rs:27 clocks.insert(name, 0);
src/lib.rs:28
src/lib.rs:29 Client {
src/lib.rs:27:28: 27:32 error: `name` does not live long enough
src/lib.rs:27 let name_str = name.as_str();
^~~~
src/lib.rs:24:37: 36:6 note: reference must be valid for the lifetime 'a as defined on the block at 24:36...
src/lib.rs:24 where T: Into<Cow<'a, str>> {
src/lib.rs:25 let uuid = Uuid::new_v4();
src/lib.rs:26 let name = uuid.to_string();
src/lib.rs:27 let name_str = name.as_str();
src/lib.rs:28 let mut clocks = HashMap::new();
src/lib.rs:29 clocks.insert(name_str, 0);