Skip to content

Instantly share code, notes, and snippets.

View JCMais's full-sized avatar
🚀
Being Happy

Jonathan Cardoso JCMais

🚀
Being Happy
View GitHub Profile
@jhartikainen
jhartikainen / gist:1326104
Created October 30, 2011 16:47
Example Doctrine 2 uniqueness validator for Zend_Form or such
<?php
use Doctrine\ORM\EntityRepository;
class Wantlet_Validate_EmailAvailable extends Zend_Validate_Abstract {
const NOT_AVAILABLE = 'notAvailable';
protected $_messageTemplates = array(
self::NOT_AVAILABLE => "Email address '%value%' is already in use"
);
@oliveiraev
oliveiraev / Makefile
Created May 29, 2012 18:32
Setup for fresh new Ubuntu-based installations
ifdef SUDO_USER
USER=$(SUDO_USER)
endif
INSTALL=apt-get install -y
INSTALL_LIB=$(INSTALL) lib$(1)-dev
REMOVE = \
apt-get purge -y $(1)*; \
@silasrm
silasrm / gist:5968028
Created July 10, 2013 16:54
Easter Eggs from Vogue British
@nodkz
nodkz / relayStore.js
Last active June 29, 2017 01:30
relayStore with `reset` and simplified `mutate` methods
let relayStore;
function relayCreateStore() {
const env = new Relay.Environment();
env.injectNetworkLayer(new Relay.DefaultNetworkLayer('/graphql'));
if (__DEV__) {
RelayNetworkDebug.init(env);
}
env.reset = () => relayCreateStore();
env.mutate = ({
query,
@efedorenko
efedorenko / gist:2028193
Created March 13, 2012 11:22
Function for alpha blending
// Turns out this function already exists in Sass: mix(fg, bg, %) (http://d.pr/mGqa)
// Alpha blending
@function blend($bg, $fg) {
$r: red($fg) * alpha($fg) + red($bg) * (1 - alpha($fg));
$g: green($fg) * alpha($fg) + green($bg) * (1 - alpha($fg));
$b: blue($fg) * alpha($fg) + blue($bg) * (1 - alpha($fg));
@ramsey
ramsey / uuid.php
Created October 26, 2016 23:37
Creating an ordered time UUID alongside a timestamp-first COMB UUID.
<?php
// composer require ramsey/uuid moontoast/math
require_once 'vendor/autoload.php';
use Ramsey\Uuid\Codec\OrderedTimeCodec;
use Ramsey\Uuid\Codec\TimestampFirstCombCodec;
use Ramsey\Uuid\Generator\CombGenerator;
use Ramsey\Uuid\UuidFactory;
@lucasbento
lucasbento / reload.sh
Created May 10, 2019 09:15
Reload react-native on Android from CLI
adb shell input keyevent 82 && adb shell input keyevent 19 && adb shell input keyevent 23
@sibelius
sibelius / MutationUtils.js
Created March 19, 2018 10:20
Helper methods for Relay Modern updater
// @flow
import { ConnectionHandler } from 'relay-runtime';
import { isObject, isArray } from 'lodash/fp';
export function listRecordRemoveUpdater({ parentId, itemId, parentFieldName, store }) {
const parentProxy = store.get(parentId);
const items = parentProxy.getLinkedRecords(parentFieldName);
parentProxy.setLinkedRecords(items.filter(record => record._dataID !== itemId), parentFieldName);
}
@sibelius
sibelius / safeGoBack.tsx
Created July 19, 2019 15:21
Safe goBack helper to avoid leaving the site
export const safeGoBack = (
history: History,
alternativeRoute: string,
) => {
if (history.length > 2) {
history.goBack();
return;
}
history.push(alternativeRoute);
@lucianomlima
lucianomlima / adb_connect.sh
Created June 5, 2019 17:57
Connect to Android devices with ADB through wi-fi
function adb_connect {
# PORT used to connect. Default: 5555
PORT=${1:-5555}
# IP address from current device connected
IP_ADDRESS=`adb shell ip route | awk '{print $9}'`
echo "ADB connect to $IP_ADDRESS on port $PORT"
# Change connection from usb to tcpip using $PORT