Skip to content

Instantly share code, notes, and snippets.

@jclosure
jclosure / gist:fbf93356010f6a035986dc04660e9aeb
Created April 18, 2016 20:21
tell elasticsearch not to analyze all fields elasticsearch
curl -X PUT 'http://localhost:9200/_template/template_1' -d '{
"template" : "*",
"mappings": {
"_default_": {
"dynamic_templates": [
{
"string_fields": {
"match": "*",
"match_mapping_type": "string",
"mapping": {
import re
# http://atomboy.isa-geek.com/plone/Members/acoil/programing/double-metaphone
from metaphone import dm as double_metaphone
# get the Redis connection
from jellybean.core import redis
import models
# Words which should not be indexed
@jclosure
jclosure / gist:2732898f35adaf4a8bb79f7805bc7d87
Created May 2, 2016 04:06
install emacs 24.5 from src on Centos 6
yum install gcc make ncurses-devel
yum install giflib-devel libjpeg-devel libtiff-devel -y
cd /usr/local/src
wget http://ftp.gnu.org/pub/gnu/emacs/emacs-24.5.tar.gz
tar xzvf emacs-24.5.tar.gz
cd emacs-24.5
./configure --without-x --without-selinux
make && make install
which emacs
emacs --version
@jclosure
jclosure / osx_hardening
Created May 10, 2016 14:59
The Ultimate OS X Hardening Guide Collection
Apple: http://www.apple.com/support/security/guides/
NSA Guide: http://www.nsa.gov/ia/_files/factsheets/macosx_hardening_tips.pdf
Mac Shadows: http://www.macshadows.com/kb/index.php?title=Hardening_Mac_OS_X
Univ. Texas: https://wikis.utexas.edu/display/ISO/Mac+OS+X+Server+Hardening+Checklist
Center for Internet Security: http://benchmarks.cisecurity.org/en-us/?route=downloads.browse.category.benchmarks.os.unix.osx
@jclosure
jclosure / check_ssl_certificate.sh
Last active May 13, 2016 13:58
get ssl certificate and mail it to me for an fqdn
#!/bin/bash
# ensure all arguments are there
if [ "$#" -ne 3 ]; then
echo "Illegal number of parameters!"
echo "EXAMPLE USAGE: " $0 " blah.somedomain.com 443 [email protected]"
exit
fi
HOSTNAME=$1
@jclosure
jclosure / ucb.py
Created May 30, 2016 17:58
trace, log, log_current_line, and interact functions for python
"""The ucb module contains functions specific to 61A at UC Berkeley."""
import code
import functools
import inspect
import re
import sys
def main(fn):
@jclosure
jclosure / ycombinator.js
Created June 5, 2016 17:47
Y-combinator function in Javascript
function Y(le) {
return (function (f) {
return f(f);
}(function (f) {
return le(function (x) {
return f(f)(x);
});
}));
}
@jclosure
jclosure / groovy_event_bus_bridge
Last active July 4, 2016 07:15
Vertx EventBusBridge server and client in Groovy
// -- server.groovy --
import io.vertx.ext.web.handler.BodyHandler
import io.vertx.ext.web.handler.sockjs.BridgeEventType
import io.vertx.groovy.core.Vertx
import io.vertx.groovy.ext.web.Router
import io.vertx.groovy.ext.web.handler.sockjs.SockJSHandler
def vertx = Vertx.vertx();
@jclosure
jclosure / JsonSerializer.java
Created July 4, 2016 07:20
General purpose Json Serializer/Deserializer Util
// jackson 2 => compile 'com.fasterxml.jackson.core:jackson-core:2.6.3'
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.codehaus.jackson.map.DeserializationConfig;
import java.io.IOException;
@jclosure
jclosure / radians.cpp
Last active September 25, 2016 21:13
Convert Degrees to Radians (C++)
#include <iostream>
#include <math.h> // for sin() and cos()
void getSinCos(double degrees, double &sinOut, double &cosOut)
{
// sin() and cos() take radians, not degrees, so we need to convert
static const double pi = 3.14159265358979323846; // the value of pi
double radians = degrees * pi / 180.0;
sinOut = sin(radians);
cosOut = cos(radians);