Skip to content

Instantly share code, notes, and snippets.

@sparkalow
sparkalow / list-files-in-folders.gs
Created Sep 21, 2016
Google Apps Script to recursively list files in a folder
View list-files-in-folders.gs
/*
Recusrsively add a list of files from a named foler to a sheet
*/
function onOpen() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var searchMenuEntries = [{
name: "Create List from Folder",
functionName: "start"
}];
View bandit_simulations.py
import numpy as np
from matplotlib import pylab as plt
#from mpltools import style # uncomment for prettier plots
#style.use(['ggplot'])
# generate all bernoulli rewards ahead of time
def generate_bernoulli_bandit_data(num_samples,K):
CTRs_that_generated_data = np.tile(np.random.rand(K),(num_samples,1))
true_rewards = np.random.rand(num_samples,K) < CTRs_that_generated_data
return true_rewards,CTRs_that_generated_data
View contextual_bandit_data_generator.py
import numpy as np
class Data_generator(object):
def __init__(self,K,d,reward_type='binary'):
self.d = d # dimension of the feature vector
self.K = K # number of bandits
self.reward_type = reward_type
View bandit_simulations.py
import numpy as np
from matplotlib import pylab as plt
#from mpltools import style # uncomment for prettier plots
#style.use(['ggplot'])
# generate all bernoulli rewards ahead of time
def generate_bernoulli_bandit_data(num_samples,K):
CTRs_that_generated_data = np.tile(np.random.rand(K),(num_samples,1))
true_rewards = np.random.rand(num_samples,K) < CTRs_that_generated_data
return true_rewards,CTRs_that_generated_data
@tsertkov
tsertkov / apache-extfilter.conf
Created Sep 9, 2013
Example of using Apache mod_ext_filter to replacing urls in proxied data (phpundercontrol).
View apache-extfilter.conf
<VirtualHost *:80>
ServerName phpuc.dev.example.com
# NB! It must be slow :-)
ExtFilterDefine fixurls mode=output intype=text/html \
cmd="/bin/sed \
-e s/http:\\/\\/localhost:/http:\\/\\/phpuc.dev.example.com:/g \
-e s/\\/phpundercontrol\\//\\//g \
-e s/\\/cruisecontrol\\/artifacts\\//\\/artifacts\\//g \
-e s/\\/cruisecontrol\\/logs\\//\\/logs\\//g \
@justinkamerman
justinkamerman / trace.py
Created Oct 12, 2012
Crawler for tracing retweet path
View trace.py
#!/usr/bin/python -u
#
# Usage: ./trace.py <tweetId>
#
import sys
import tweepy
import Queue
import time
import json
@mbostock
mbostock / .block
Last active Jul 29, 2020
Line Transition
View .block
license: gpl-3.0
@nomatteus
nomatteus / format_html.py
Created Oct 17, 2011
Format HTML Using Python (Non-destructive, unlike HTML Tidy)
View format_html.py
##
# This is a quick script that will format/indent HTML
# HTML Tidy is often too destructive, especially with bad HTML, so we're using Beautiful Soup
##
# USAGE: Designed to be used on the command line, just pipe HTML to it, and it will output
# cat file.html | python format_html.py
###
# Download & Install Beautiful Soup, if you don't have it already:
# Go to the Beautiful Soup web site, http://www.crummy.com/software/BeautifulSoup/
# Download the package
@nz
nz / Delete all documents in a Solr index using curl.md
Last active Jul 12, 2020
Delete all documents in a Solr index using curl
View Delete all documents in a Solr index using curl.md
# http://wiki.apache.org/solr/FAQ#How_can_I_delete_all_documents_from_my_index.3F
# http://wiki.apache.org/solr/UpdateXmlMessages#Updating_a_Data_Record_via_curl

curl "http://index.websolr.com/solr/a0b1c2d3/update?commit=true" -H "Content-Type: text/xml" --data-binary '<delete><query>*:*</query></delete>'

I'm amused at the traction this little gist is getting on Google! I would be remiss not to point out that six+ years later I'm still helping thousands of companies on a daily basis with their search index management, by providing managed Solr as a service over at Websolr, and hosted Elasticsearch at Bonsai. Check us out if you'd like an expert helping hand at Solr and Elasticsearch hosting, ops and support!

You can’t perform that action at this time.