Skip to content

Instantly share code, notes, and snippets.

@loopiezlol
loopiezlol / git-lambda.js
Created April 10, 2018 14:12
flow showing off how to clone, update and push to a git repo from an AWS lambda function
const fs = require('fs')
const path = require('path')
const process = require('process')
const { spawnSync } = require('child_process')
const { GITHUB_TOKEN, GITHUB_USERNAME, GITHUB_EMAIL } = process.env
// leaving this without https:// in order to reuse it when adding the remote
const gitRepositoryURL = 'github.com/owner/repo-name.git'
const repositoryName = 'repo-name'
@avaliani
avaliani / geocoder-service.js
Last active February 3, 2022 16:13 — forked from benmj/geocoder-service.js
This is a fork of @benmj 's Angular JS Geocoder service. It fixes the following bugs (1) rootscope apply missing, (2) executeNext() not being called if the response type is 'zero results', 'request denied' or 'invalid result', and (3) it simplifies the query pause logic (no increasing pause times and tasks are rejected if we are still over quota…
/*
* An AngularJS Service for intelligently geocoding addresses using Google's API. Makes use of
* localStorage (via the ngStorage package) to avoid unnecessary trips to the server. Queries
* Google's API synchronously to avoid `google.maps.GeocoderStatus.OVER_QUERY_LIMIT`.
*
* @author: benmj
* @author: amir.valiani
*
* Original source: https://gist.github.com/benmj/6380466
*/
@debloper
debloper / bandwidth.js
Last active November 5, 2023 19:15
Determine client's connection speed with JavaScript
// Let's initialize the primitives
var startTime, endTime, fileSize;
// Set up the AJAX to perform
var xhr = new XMLHttpRequest();
// Rig the call-back... THE important part
xhr.onreadystatechange = function () {
// we only need to know when the request has completed
@mateuslinhares
mateuslinhares / ES_Stemming.rb
Created March 26, 2012 18:04 — forked from hohyon-ryu/ES_Stemming.rb
Stemming for ElasticSearch (Portuguese example)
# Script to test stemming for ElasticSearch. Working now!!
# Reference: http://stackoverflow.com/questions/4981001/why-elasticsearch-is-not-finding-my-term
require 'rubygems'
require 'net/http'
require 'yaml'
require 'json'
# kill the index
delete = Net::HTTP::Delete.new("/willindex")
@karmi
karmi / tagcloud.sh
Last active September 4, 2017 02:01
Simple tag cloud with ElasticSearch `terms` facet
# (Re)create the index
curl -X DELETE "http://localhost:9200/tagcloud"
curl -X PUT "http://localhost:9200/tagcloud"-d '{
"settings" : {
"index" : {
"number_of_shards" : 1,
"number_of_replicas" : 0
}
}
}'
@markbates
markbates / watchr script
Created July 20, 2010 15:25
A Watchr script for rails, rspec, and cucumber
ENV["WATCHR"] = "1"
system 'clear'
def growl(message)
growlnotify = `which growlnotify`.chomp
title = "Watchr Test Results"
puts message
image = message.match(/\s0\s(errors|failures)/) ? "~/.watchr_images/passed.png" : "~/.watchr_images/failed.png"
options = "-w -n Watchr --image '#{File.expand_path(image)}' -m '#{message}' '#{title}'"
system %(#{growlnotify} #{options} &)