Skip to content

Instantly share code, notes, and snippets.

@agarzon
agarzon / CakePHPHelper.php
Created November 5, 2014 14:40
CakePHP helper for Codeception (Unit testing)
<?php
namespace Codeception\Module;
class CakePHPHelper extends \Codeception\Module
{
public function __construct()
{
define('APP_DIR', 'app');
define('DS', DIRECTORY_SEPARATOR);
define('ROOT', getcwd());
@gubatron
gubatron / multiple-deploy-keys-multiple-private-repos-github-ssh-config.md
Last active October 12, 2024 22:57
How to configure multiple deploy keys for different private github repositories on the same computer without using ssh-agent

How to configure multiple deploy keys for different private github repositories on the same computer without using ssh-agent

Let's say alice is a github.com user, with 2 or more private repositories repoN. For this example we'll work with just two repositories named repo1 and repo2

https://github.com/alice/repo1

https://github.com/alice/repo2

You need to be to pull from these repositories without entering a passwords probably on a server, or on multiple servers.

@simkimsia
simkimsia / install-cake3-ubuntu-14-04.sh
Last active August 29, 2015 14:07
preparing fresh 14.04 ubuntu install for cake 3
#!/bin/bash
###
#
# forked from https://gist.github.com/1264701/08f93534ba177f173b9382b53c419cd0de5b07ea
#
# Ubuntu 14.04 based web server installation script
# Run this by executing the following from a fresh install of Ubuntu 14.04 server:
#
# bash -c "$(curl -fsSL https://gist.githubusercontent.com/simkimsia/4a3808cd109dbd1a3913/raw/d0a9799cdbf0857043b7b59a489361388c09fc4a/install-cake3-ubuntu-14-04.sh)" <mysqlPassword>
@markhu
markhu / edict.py
Last active August 15, 2023 11:54
edict: load JSON into Python object but access with .dot notation
class edict(dict): # Similar to bunch, but less, and JSON-centric
# based on class dotdict(dict): # from http://stackoverflow.com/questions/224026/dot-notation-for-dictionary-keys
__setattr__= dict.__setitem__ # TBD: support assignment of nested dicts by overriding this?
__delattr__= dict.__delitem__
def __init__(self, data):
if type(data) in ( unicode, str ):
data = json.loads( data)
@mplewis
mplewis / safe_schedule.py
Last active December 19, 2024 08:52
An implementation of Scheduler that catches jobs that fail. For use with https://github.com/dbader/schedule
import logging
from traceback import format_exc
import datetime
from schedule import Scheduler
logger = logging.getLogger('schedule')
@sebmarkbage
sebmarkbage / transferring-props.md
Last active September 27, 2024 00:10
Deprecating transferPropsTo

Deprecating transferPropsTo

It's a common pattern in React to wrap a component in an abstraction. The outer component exposes a simple property to do something that might have more complex implementation details.

We used to have a helper function called transferPropsTo. We no longer support this method. Instead you're expected to use a generic object helper to merge props.

render() {
 return Component(Object.assign({}, this.props, { more: 'values' }));
@staltz
staltz / introrx.md
Last active April 17, 2025 06:34
The introduction to Reactive Programming you've been missing
@simkimsia
simkimsia / convert_query_string_to_assoc_array.js
Created April 28, 2014 13:45
able to convert query string like ?q=abc&g[]=1&g[]=2 into a javascript object (params) which has 2 params q & g. The params.q will be 'abc' string while params.g will be an array containing the value 1, 2
RegExp.quote = function(str) {
return (str+'').replace(/([.?*+^$[\]\\(){}|-])/g, "\\$1");
}
function getSearchParameters() {
var prmstr = window.location.search.substr(1);
return prmstr != null && prmstr != "" ? transformToAssocArray(prmstr) : {};
}
function transformToAssocArray( prmstr ) {
@yashuarc
yashuarc / enable_cors_on_cakephp.php
Last active October 28, 2024 19:32
Enabling CORS on CakePHP
public function beforeFilter() {
parent::beforeFilter();
$this->response->header('Access-Control-Allow-Origin','*');
$this->response->header('Access-Control-Allow-Methods','*');
$this->response->header('Access-Control-Allow-Headers','X-Requested-With');
$this->response->header('Access-Control-Allow-Headers','Content-Type, x-xsrf-token');
$this->response->header('Access-Control-Max-Age','172800');
}
@octocat
octocat / .gitignore
Created February 27, 2014 19:38
Some common .gitignore configurations
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #