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 / waitJavascript.js
Created May 19, 2012 07:05
javascript wait function
function wait(callback, delay){
var startTime = new Date().getTime();
while (new Date().getTime() < startTime + delay);
callback();
}
@jonalmeida
jonalmeida / mindlesscoding.js
Created May 19, 2012 07:21
what i understood from inimino
setTimeout(
function(){
console.log(document.getElementById("list").children[i]);
setTimeout(
function(){
console.log(document.getElementById("list").children[i]);
}, 2000);
}, 2000);
var items=[1,2,3];
foo = function(items, 1000){
bar = function(items[0]);
setTimeout( function(){
foo(items.slice(1), 1000
}, 1000)
}
#!/bin/env python
for x in xrange(1, 101):
# Calculate once, refer to the results again instead of re-calculating
isFive = (x%5 == 0)
isThree = (x%3 == 0)
if(isFive & isThree):
print "CracklePop"
elif(isFive):
print "Pop"

Keybase proof

I hereby claim:

  • I am jonalmeida on github.
  • I am jonalmeida (https://keybase.io/jonalmeida) on keybase.
  • I have a public key whose fingerprint is 831C F54A 918F 0986 6E4A 7E59 1DB0 4496 F117 C452

To claim this, I am signing this object:

@jonalmeida
jonalmeida / Posting data
Last active August 29, 2015 14:03
What's the correct way to use inDatabase: within an async networking call?
- (void) sendPostData:(NSDictionary *)data withDbIndexArray:(NSMutableArray *)dbIndexArray {
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.requestSerializer = [AFJSONRequestSerializer serializer];
[manager POST:[_urlEndpoint absoluteString] parameters:data success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"JSON: %@", responseObject);
[_dbQueue inDatabase:^(FMDatabase *db) {
for (int i=0; i < dbIndexArray.count; i++) {
NSLog(@"Removing event at index: %@", dbIndexArray[i]);
[_db removeEventWithId:[[dbIndexArray objectAtIndex:i] longLongValue]];

Business Models

Advertising

Models Examples
Display ads Yahoo!
Search ads Google

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"

Results

@jonalmeida
jonalmeida / vimrc
Created November 24, 2014 21:40
Current vim config
set ffs=unix,dos,mac " set file formats
set number " line numbers
set background=dark " background
colorscheme vividchalk " theme
"colorscheme molokai
"let g:molokai_original = 1
call pathogen#incubate()
call pathogen#helptags()
filetype off
syntax on
@jonalmeida
jonalmeida / reverse_hash.cpp
Created November 29, 2014 02:29
ReverseTheHash
#include <iostream>
#include <string>
#include <inttypes.h>
int main( int argc, char *argv[] ) {
uint64_t h = 25180466553932;
std::string letters = "acdegilmnoprstuw";
std::string answer = "";