Skip to content

Instantly share code, notes, and snippets.

@dhoelzgen
dhoelzgen / base_controller.rb
Last active October 7, 2021 16:19
CORS in Rails 4 APIs
class API::V1::BaseController < ApplicationController
skip_before_filter :verify_authenticity_token
before_filter :cors_preflight_check
after_filter :cors_set_access_control_headers
def cors_set_access_control_headers
headers['Access-Control-Allow-Origin'] = '*'
headers['Access-Control-Allow-Methods'] = 'POST, GET, PUT, DELETE, OPTIONS'
@staltz
staltz / introrx.md
Last active May 7, 2024 09:38
The introduction to Reactive Programming you've been missing
@macbleser
macbleser / wp-permissions-script
Created February 21, 2014 15:37
WordPress Permissions Configuration Script
#!/bin/bash
#
# This script configures WordPress file permissions based on recommendations
# from http://codex.wordpress.org/Hardening_WordPress#File_permissions
#
# Author: Michael Conigliaro
#
WP_OWNER=changeme # &lt;-- wordpress owner
WP_GROUP=changeme # &lt;-- wordpress group
WP_ROOT=/home/changeme # &lt;-- wordpress root directory
@mark-sch
mark-sch / nsupdate.php
Created February 20, 2014 08:42
PHP script to automate nsupdate calls for dynamic dns updates. This script and a properly configured bind nameserver allows hosting of custom dyndns services, e.g. updating own domain from Fritzbox.
<?php
// *** PHP script to automate nsupdate calls for dynamic dns updates.
// *** This script and a properly configured bind nameserver allows hosting
// *** of custom dyndns services, e.g. updating own domain from Fritzbox.
// *** usage: http://192.168.0.25/nsupdate.php?ns=ns0.mynameserver.de&domain=my.domain.de;my.domain2.de&newip=<ipaddr>
if (!isset($_SERVER['PHP_AUTH_USER']))
{
Header("WWW-Authenticate: Basic realm=\"Configurations-Editor\"");
Header("HTTP/1.0 401 Unauthorized");
@rknell
rknell / build-release.sh
Last active November 7, 2023 08:23
Build Android Release apk from Cordova /CLI
#!/bin/bash
#Thanks to this page: http://chris-allen-lane.com/2012/12/phonegap-compiling-a-release-apk-without-using-phonegap-build/
#USAGE!
# 1. Replace <AndroidKeyName> with the filename of the keyfile generated (see url)
# 2. Replace <ProjectName> with the project name in the generated file form cordova, see path/to/my/project/platforms/android/bin and look for an APK if you need help
# 3. Replace <AndroidKeyNameAlias> from the alias used when generating the key (see url again!)
# 4. Edit path/to/my/project/platforms/android/AndroidManifest.xml and change "debuggable=false" (search for it!)
# 5. Check path/to/my/project/Release/android for your sparkling new apk!
#
# This worked and was uploadable to the google play store.
@idosela
idosela / http-response-interceptor.js
Last active February 25, 2024 12:51
Sample code for ng-conf 2014
angular.module('myMdl', []).config(['$httpProvider', function($httpProvider) {
$httpProvider.responseInterceptors.push([
'$q', '$templateCache', 'activeProfile',
function($q, $templateCache, activeProfile) {
// Keep track which HTML templates have already been modified.
var modifiedTemplates = {};
// Tests if there are any keep/omit attributes.
var HAS_FLAGS_EXP = /data-(keep|omit)/;
@pklaus
pklaus / ddns.py
Last active September 17, 2021 12:42
A script to update the A and AAAA RRs of HOSTNAME on a DNS server according to your current external IP address using nsupdate / TSIG. This script is tested to run on Mac OS X (10.8-10.9) but you should be able to get it up and running in almost no time on any Unix or Linux system that ships nsupdate. I use this script to update my own DDNS serv…
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Written on 2013-02-04 by Philipp Klaus <philipp.l.klaus →AT→ web.de>.
Check <https://gist.github.com/4707775> for newer versions.
Uses dnspython: install with `pip install dnspython3`
"""
@Sentences
Sentences / response.php
Created October 24, 2012 10:38
Laravel Response extend for inline displaying of images
<?php
use Laravel\File;
/**
* Put this in laravels libraries dir and make sure to
* remove Response in /config/application.php
* This file will be autoloaded by default.
*
* @author Nico R <lt500r@gmail.com>
*/
class Response extends \Laravel\Response
@bclinkinbeard
bclinkinbeard / README.md
Created August 21, 2012 01:35
AngularJS Response Interceptor Demo

This is a simple demo of how to create and use a Response Interceptor in AngularJS. In this case we are using the interceptor to convert the objects created from a JSON data load into typed instances of a custom "class".