Skip to content

Instantly share code, notes, and snippets.

View ssx's full-sized avatar

Scott Robinson ssx

View GitHub Profile
@Djuki
Djuki / deploy.sh
Last active August 29, 2015 14:04
Deploy script for Laravel apps
# stop script on error signal
set -e
# delete deployment folder if script exit before end last time
if [ -d "/home/forge/deployment" ]; then
rm -R /home/forge/deployment
fi
# set up your env variables if your app using them
export DB_HOST=localhost
@ijansch
ijansch / jsonarrayfun.php
Last active August 29, 2015 14:05
2 common issues in php based apis
<?php
// Issue 1, empty associative arrays (dictionaries) become regular arrays.
$dictionary = array('key' => 'value');
var_dump(json_encode($dictionary)); // gives '{"key":"value"}';
unset($dictionary['key']);
var_dump(json_encode($dictionary)); // Gives '[]' -> json dictionary turned into array
@pec1985
pec1985 / ResizingImages.js
Created March 10, 2011 23:04
Resize images from the Image Gallery
// testend on iOS
/*
Copyright 2011 Pedro Enrique
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
@stith
stith / .htaccess
Created May 6, 2011 03:41
The ultimate Magento SEO .htaccess rewrite rule set
# Grab the protocol being used
RewriteCond %{HTTPS} =on
RewriteRule ^(.+)$ - [env=ps:https]
RewriteCond %{HTTPS} !=on
RewriteRule ^(.+)$ - [env=ps:http]
# Force WWW
RewriteCond %{HTTP_HOST} !^www\.
@slojo404
slojo404 / logstash RPM spec
Created March 28, 2012 18:11 — forked from paul-at/logstash RPM spec
logstash monolithic init script and spec file for CentOS / RedHat
Name: logstash
Version: 1.1.0
Release: 1%{?dist}
Summary: logstash is a tool for managing events and logs
Group: System/Logging
License: ASL 2.0
URL: http://logstash.net/
Source0: http://semicomplete.com/files/logstash/logstash-%{version}-monolithic.jar
Source1: logstash
@macdonst
macdonst / IMEI.java
Created April 20, 2012 15:13
IMEI Plugin for PhoneGap 1.4.1
package com.simonmacdonald.imei;
import org.json.JSONArray;
import android.content.Context;
import android.telephony.TelephonyManager;
import com.phonegap.api.Plugin;
import com.phonegap.api.PluginResult;
@zaeleus
zaeleus / gitlab_centos6.txt
Created December 23, 2012 08:04
Gitlab install on CentOS 6.3 (2012-09-13)
-- install packages
# yum update
# yum groupinstall "Development Tools" "Additional Development"
-- epel for redis, libyaml, pip, qtwebkit-devel
# rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-7.noarch.rpm
# yum install libicu-devel libyaml-devel redis wget python-pip qt-devel qtwebkit-devel
-- install ruby
@damienalexandre
damienalexandre / pony.sh
Created April 15, 2013 09:13
Facets example with ElasticSearch. Building a Filtered Query manualy (or via Elastica) is hell.
# for real, I have a mapping and my color is not "indexed"
curl -XPUT 'http://localhost:9200/pony_index_tmp' -d '
{
settings: {
number_of_shards: 1,
number_of_replicas: 0
}
}'
curl -XPOST "http://localhost:9200/pony_index_tmp/pony/1" -d '
@julien-c
julien-c / global.php
Last active December 16, 2015 16:09
Sentry/Monolog integration in Laravel 4
<?php
if (Config::has('sentry.key')) {
$bufferHandler = new Monolog\Handler\BufferHandler(
new Monolog\Handler\RavenHandler(
new Raven_Client(Config::get('sentry.key')),
Monolog\Logger::WARNING
)
);
@nickdunn
nickdunn / gist:5607392
Last active December 17, 2015 12:09
I run ElasticSearch on the same box as my Apache webserver (one single VPS). I authenticate every request to ElasticSearch.
1. Drop all incoming connections to ElasticSearch on port 9200:
iptables -A INPUT -j DROP -p tcp --destination-port 9200 -i eth0
2. Persist this change on reboot:
iptables-save > /root/my_iptables_config
/sbin/iptables-restore < /root/my_iptables_config
3. Create a directory in your web application, I usually name mine /_es and add an .htaccess file.