Skip to content

Instantly share code, notes, and snippets.

@miguelbermudez
miguelbermudez / measure_webiste_response
Created December 10, 2012 19:21
Bash script quickly getting timed response from url
#!/bin/bash
CURL="/usr/bin/curl"
GAWK="/opt/local/bin/gawk"
echo "Please pass the url you want to measure: "
read url
URL="$url"
result=`$CURL -o /dev/null -s -w %{time_connect}:%{time_starttransfer}:%{time_total} $URL`
echo " Time_Connect Time_startTransfer Time_total "
echo $result | $GAWK -F: '{ print $1" "$2" "$3}'
@miguelbermudez
miguelbermudez / hnlinks.js
Created December 12, 2012 19:24
Ever wanted to get all of those useful links that show up in the comments for a Hacker News Post? Uses PhantomJS.
@miguelbermudez
miguelbermudez / clean_foldernames.rb
Created December 26, 2012 04:33
Sanitize folder names
#!/usr/bin/env ruby
# encoding: utf-8
require 'fileutils'
require 'pathname'
require 'paperclip-strip-strange-characters'
WORKING_DIR = Pathname.getwd
dir_to_glob = ARGV[0]
@miguelbermudez
miguelbermudez / file_cleaner.rb
Created December 30, 2012 00:34
Ruby command utility for scrubbing filenames
#!/usr/bin/env ruby -W0
# encoding: utf-8
require 'fileutils'
require 'pathname'
require 'paperclip-strip-strange-characters'
filename = ARGV[0]
ext = File.extname(filename)
#referenced fields
referenced_color_fields = ['palette', 'dominantcolor', 'searchbycolors', 'mostsaturated', ]
referenced_text_fields = ['references', 'exhibitionHistory', 'notes']
work_keys = ["id", "accessionNumber", "artist", "catalogueEntry", "catalogueRaisonne", "classification", "creditLine", "culture", "date", "description", "designer", "dimensions", "dynasty", "galleryLabel", "geography", "imageUrl", "imgfilename", "markings", "medium", "period", "provenance", "reign", "rightsReproduction", "title", "workid", "workurl"]
for item in r.iter_lines():
work_dict = json.loads(item)
#work dict copy for new work model creation
@miguelbermudez
miguelbermudez / jsonToMongo.php
Last active December 17, 2015 05:28
Take a list of json files in a directory and import them into mongo using mongoimport.
<?php
//get directory from argv
$dir = $argv[1];
$db = $argv[2];
$collection = $argv[3];
//file handle
$filehandle = opendir($dir);
$counter = 1;
#!/bin/bash
# log into your server
ssh root@[server ipaddress]
# change root password
passwd
# update all packages and operating system
apt-get update && apt-get --yes upgrade
@miguelbermudez
miguelbermudez / allowJSONPCallback.py
Created June 10, 2013 02:00
Django JSONP Decorator
#From: http://djangosnippets.org/snippets/2208/
#Author: cominataci, http://djangosnippets.org/users/cominatchu/
from django.http import HttpResponse
from django.contrib.auth.decorators import login_required
class AllowJSONPCallback(object):
"""This decorator function wraps a normal view function
so that it can be read through a jsonp callback.
@miguelbermudez
miguelbermudez / index.html
Created June 16, 2013 08:06
New Coming Soon Page for miguelbermudez.com
<!doctype html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title></title>
<meta name="description" content="">
@miguelbermudez
miguelbermudez / Works
Created July 8, 2013 21:14
Works Proto
// Works.proto
package CG.Works;
// Work
message Work {
required int32 id = 16
required string accessionNumber = 17
optional string artist = 18
optional string catalogueEntry = 19
optional string catalogueRaisonne = 20