Skip to content

Instantly share code, notes, and snippets.

View aloncarmel's full-sized avatar
🤘
❤️ Having fun!

Alon Carmel aloncarmel

🤘
❤️ Having fun!
View GitHub Profile
@aloncarmel
aloncarmel / socketconnect.js
Created July 13, 2014 11:30
Implement socket.io inside chrome extension or other internal JS files using jquery.
//Socket server connect to listen to data.
$.getScript('http://yoursocketioserver/socket.io/socket.io.js',function() {
socket = io.connect('http://lyoursocketioserver');
socket.on('connect', function(){
socket.on('message', function (data) {
@aloncarmel
aloncarmel / capture
Created January 23, 2014 15:20
A try to capture chrome pages using the pagecapture and create an image of them. NOT working.
chrome.pageCapture.saveAsMHTML({'tabId':1654}, function(mhtmlData){
var reader = new FileReader();
reader.readAsText(mhtmlData);
reader.onloadend = function() {
var html = reader.result;
d = document.createElement('div');
function setWeatherIcon(condid) {
switch(condid) {
case '0': var icon = '<i class="wi-tornado"></i>';
break;
case '1': var icon = '<i class="wi-storm-showers"></i>';
break;
case '2': var icon = '<i class="wi-tornado"></i>';
break;
case '3': var icon = '<i class="wi-thunderstorm"></i>';
@aloncarmel
aloncarmel / encryptor.js
Last active January 1, 2016 07:29
Encrypt and Decrypt text on nodejs with callbacks.
//Encrypt data, call callback when done for make sure everything is done.
function EncryptText(text,key,callback) {
console.log('Encrypting text');
var cipher = crypto.createCipher('aes-256-cbc',key)
var crypted = cipher.update(text,'utf8','hex')
crypted += cipher.final('hex');
@aloncarmel
aloncarmel / gist:6404647
Created September 1, 2013 14:02
Small experiement to start writing my own related content engine on app engine using search api and some basic levenshtein. * Grabs keywords per url from textwise.com * Writes full text search in app engine, creates a hash. * Grab url and keywords, compare hashes after keyword search. Its a start. never been tested.
#!/usr/bin/env python
#
# Copyright 2007 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@aloncarmel
aloncarmel / randombg.js
Created August 20, 2013 13:35
Grab a random background from unsplash.com and apply to a div.
function GetRandomBackground()
{
var url = 'http://unsplash.com/rss';
$.ajax({
url: document.location.protocol + '//ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=10&callback=?&q=' + encodeURIComponent(url),
async: false,
jsonpCallback: 'jsonCallback',
contentType: "application/json",
@aloncarmel
aloncarmel / stop_words.txt
Created June 4, 2012 09:40 — forked from DarrenN/stop_words.txt
Naively parse a text removing stopwords
'tis
'twas
a
aah
aaron
abandon
abandoned
abbott
abby
abe