Skip to content

Instantly share code, notes, and snippets.

@lucaswxp
lucaswxp / Check field exists in model django snippet.md
Last active June 30, 2024 03:00
Check field exists in model django snippet

In your models.py put:

from django.db import models

@classmethod
def model_field_exists(cls, field):
    try:
        cls._meta.get_field(field)
 return True

2015-01-29 Unofficial Relay FAQ

Compilation of questions and answers about Relay from React.js Conf.

Disclaimer: I work on Relay at Facebook. Relay is a complex system on which we're iterating aggressively. I'll do my best here to provide accurate, useful answers, but the details are subject to change. I may also be wrong. Feedback and additional questions are welcome.

What is Relay?

Relay is a new framework from Facebook that provides data-fetching functionality for React applications. It was announced at React.js Conf (January 2015).

@luw2007
luw2007 / pyuno_in_ubuntu_14.md
Created January 16, 2015 09:07
Python 2.7 with pyuno in ubuntu

##ubuntu 13.10 and later , you need to install openoffice 4.1.1

###1. uninstall libreoffice and openoffice

sudo apt-get remove libreoffice* openoffice*
sudo apt-get autoremove

###2. install Apache OpenOffice 4.1.1 on 64 bit Ubuntu

wget sourceforge.net/projects/openofficeorg.mirror/files/4.1.1/binaries/en-GB/Apache_OpenOffice_4.1.1_Linux_x86-64_install-deb_en-GB.tar.gz

@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 October 26, 2025 03:06
The introduction to Reactive Programming you've been missing