Skip to content

Instantly share code, notes, and snippets.

@teebu
teebu / elasticsearch.monit
Last active April 15, 2016 19:14 — forked from gacha/elasticsearch.monit
Elasticsearch monit
check process elasticsearch with pidfile /var/run/elasticsearch.pid
start program = "/etc/init.d/elasticsearch start"
stop program = "/etc/init.d/elasticsearch stop"
if 5 restarts within 5 cycles then timeout
if failed host 127.0.0.1 port 9200 protocol http then restart
function getOutputResolution(max_width, max_height, videoInfo) {
var tmp_max_width = 0
var tmp_max_height = 0
// ShrinkToFit: don't scale up videos
max_width = (max_width > videoInfo.width) ? videoInfo.width : max_width
max_height = (max_height > videoInfo.height) ? videoInfo.height : max_height
if (videoInfo.width < videoInfo.height) { // for portrait
tmp_max_width = Math.min(max_width, max_height) // getting the smallest number for width
tmp_max_height = Math.max(max_width, max_height) // getting the biggest number for height
"title-suggest": {
"type": "completion",
"analyzer": "simple",
"payloads": false,
"preserve_separators": true,
"preserve_position_increments": true,
"max_input_length": 30
},
"name-suggest": {
"type": "completion",
@teebu
teebu / get-endpoints.sh
Created August 27, 2016 03:23 — forked from Mpdreamz/get-endpoints.sh
Get all of elasticsearch's REST endpoints, come up with method names for them and dedup them, Used in newer versions of NEST to generate the raw client (if you only need to pass and receive strings from the client. Scroll down for example output
#!/bin/bash
# This scripts scans the elasticsearch source code for all the registered REST endpoints
# It will put the formatted output in $DEFINITIONOUTPUTFILE
# [MethodName] [HttpVerb] [Route]
ESFOLDER="../elasticsearch"
DEFINITIONOUTPUTFILE="src/Generated/rest-actions.txt"
# Find all the lines that registerHandlers
@teebu
teebu / slugify.js
Created September 14, 2016 21:55 — forked from mathewbyrne/slugify.js
Javascript Slugify
function slugify(text)
{
return text.toString().toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
.replace(/\-\-+/g, '-') // Replace multiple - with single -
.replace(/^-+/, '') // Trim - from start of text
.replace(/-+$/, ''); // Trim - from end of text
}
@teebu
teebu / ipin.py
Created September 21, 2016 01:24 — forked from urielka/ipin.py
iOS PNG uncrushers based on http://www.axelbrz.com.ar/?mod=iphone-png-images-normalizer with a fix for multiple IDAT
#---
# iPIN - iPhone PNG Images Normalizer v1.0
# Copyright (C) 2007
#
# Author:
# Axel E. Brzostowski
# http://www.axelbrz.com.ar/
# axelbrz@gmail.com
#
# References:
@teebu
teebu / png.rb
Created September 21, 2016 08:04 — forked from AquaGeek/png.rb
Ruby code to reverse iPhone PNG optimizations
# Helper method to fix Apple's stupid png optimizations
# Adapted from:
# http://www.axelbrz.com.ar/?mod=iphone-png-images-normalizer
# https://github.com/peperzaken/iPhone-optimized-PNG-reverse-script/blob/master/Peperzaken/Ios/DecodeImage.php
# PNG spec: http://www.libpng.org/pub/png/spec/1.2/PNG-Contents.html
require 'zlib'
require 'logger'
module PNG
@teebu
teebu / url_slug.js
Created December 9, 2016 02:27 — forked from sgmurphy/url_slug.js
URL Slugs in Javascript (with UTF-8 and Transliteration Support)
/**
* Create a web friendly URL slug from a string.
*
* Requires XRegExp (http://xregexp.com) with unicode add-ons for UTF-8 support.
*
* Although supported, transliteration is discouraged because
* 1) most web browsers support UTF-8 characters in URLs
* 2) transliteration causes a loss of information
*
* @author Sean Murphy <sean@iamseanmurphy.com>
@teebu
teebu / index.html
Last active December 31, 2016 03:50 — forked from anonymous/index.html
HTTPS fix for apple image sources. JS Bin// source http://jsbin.com/jozotajuro
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
@teebu
teebu / aws-sns-example.js
Created March 30, 2017 19:15 — forked from tmarshall/aws-sns-example.js
aws-sdk sns example, in Node.js
var AWS = require('aws-sdk');
AWS.config.update({
accessKeyId: '{AWS_KEY}',
secretAccessKey: '{AWS_SECRET}',
region: '{SNS_REGION}'
});
var sns = new AWS.SNS();