Skip to content

Instantly share code, notes, and snippets.

ando dre1080

Block or report user

Report or block dre1080

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@dre1080
dre1080 / api.php
Created May 16, 2017
Disable WordPress REST API endpoints
View api.php
// Remove init rest routes
remove_action( 'rest_api_init', 'create_initial_rest_routes', 0 );
// Remove oembed rest routes
function remove_json_api () {
// Remove the REST API lines from the HTML Header
remove_action( 'wp_head', 'rest_output_link_wp_head', 10 );
remove_action( 'wp_head', 'wp_oembed_add_discovery_links', 10 );
@dre1080
dre1080 / dev-tld.md
Created Sep 27, 2016 — forked from marek-saji/dev-tld.md
Configure local DNS server to serve #dev #TLD #ubuntu #linux
View dev-tld.md

Configure local wildcard DNS server

  1. Install Dnsmasq: sudo apt-get install dnsmasq
  2. Since Ubuntu's NetworkManager uses dnsmasq, and since that messes things up a little for us, open up /etc/NetworkManager/NetworkManager.conf and comment out (#) the line that reads dns=dnsmasq. Restart NetworkManager afterwards: sudo restart network-manager.
  3. Make sure Dnsmasq listens to local DNS queries by editing /etc/dnsmasq.conf, and adding the line listen-address=127.0.0.1.
  4. Create a new file in /etc/dnsmasq.d (eg. /etc/dnsmasq.d/dev), and add the line address=/dev/127.0.0.1 to have dnsmasq resolve requests for *.dev domains. Restart Dnsmasq: sudo /etc/init.d/dnsmasq restart.

source: http://brunodbo.be/blog/2013/04/setting-up-wildcard-apache-virtual-host-wildcard-dns

@dre1080
dre1080 / soft-delete.sql
Last active Feb 10, 2016
Soft-deletable records in Postgres
View soft-delete.sql
CREATE FUNCTION soft_delete()
RETURNS trigger AS $$
BEGIN
EXECUTE 'UPDATE '
|| TG_TABLE_NAME
|| ' SET deleted_at = current_timestamp WHERE id = $1'
USING OLD.id;
RETURN OLD;
END;
$$ LANGUAGE plpgsql
@dre1080
dre1080 / util.go
Last active Sep 30, 2015
Print Echo registered routes
View util.go
package util
import (
"log"
"strings"
"github.com/labstack/echo"
)
// DebugPrintRoutes prints all registered routes of e.
View box-shadow.html
<!DOCTYPE html>
<html>
<head>
<title>Box Shadow</title>
<style>
.box {
height: 150px;
width: 300px;
margin: 20px;
View database.rake
require 'yaml'
require 'logger'
require 'active_record'
namespace :db do
def create_database config
options = {:charset => 'utf8', :collation => 'utf8_unicode_ci'}
create_db = lambda do |config|
ActiveRecord::Base.establish_connection config.merge('database' => nil)
@dre1080
dre1080 / all2coffee.sh
Created Nov 9, 2013
Js2Coffee a directory recursively. Excludes node_modules, app/assets and public directories.
View all2coffee.sh
for FILE in `find . -name "*.js" -type f -o -path './node_modules' -prune -o -path './app/assets' -prune -o -path './public' -prune`
do
if [ -e $FILE ] ; then
COFFEE=${FILE//.js/.coffee}
echo "converting ${FILE} to ${COFFEE}"
js2coffee "$FILE" > "$COFFEE"
else
echo "File: {$1} does not exist!"
fi
View pesapal.rb
module PesaPal
require 'active_support'
include ActiveSupport::Configurable
self.configure do |config|
config.test_mode = true
config.consumer_key = "<your key>"
config.consumer_secret = "<your secret>"
end
View gist:5943470
brew update
brew versions FORMULA
cd `brew --prefix`
git checkout HASH Library/Formula/FORMULA.rb # use output of "brew versions"
brew install FORMULA
brew switch FORMULA VERSION
git checkout -- Library/Formula/FORMULA.rb # reset formula
## Example: Using Subversion 1.6.17
#
You can’t perform that action at this time.