Skip to content

Instantly share code, notes, and snippets.

View octopitus's full-sized avatar

Luy Tran octopitus

View GitHub Profile
@brigand
brigand / app.js
Last active June 29, 2017 15:52
React JS Event-Emitter Mixin and Example
var React = require("react"), Dom = React.DOM;
var LogOutButton = require('./src/logout');
var events = require('api/events');
var Main = React.createClass({
// this mixin provides this.emitLogout, and if we set onLogout it'll be called when "logout" is emitted
mixins: [events.mixinFor("logout")],
getInitialState: function(){
return {
@zone117x
zone117x / crypto-webworker-support-check.js
Created January 15, 2019 14:43
Check for web worker Crypto API support
// Checks if the global.crypto API is supported inside web workers.
// Uses a serialized function inside a Blob URL to run a web worker
// without an external file.
// See https://medium.com/@roman01la/run-web-worker-with-a-function-rather-than-external-file-303add905a0
function checkCryptoWorkerSupport() {
return new Promise((resolve) => {
const checkFn = () => {
const cryptoSupported = self.crypto && self.crypto.getRandomValues
postMessage(!!cryptoSupported)
@RyanMillerC
RyanMillerC / set-primary-monitor-pantheon-greeter
Last active November 7, 2020 13:29
Set correct primary monitor for login screen when lightdm greeter starts up on Elementary OS
#!/bin/bash
#
# Created: 2017-07-02 16:20
# Updated: 2018-02-09 12:23
# Creator: Ryan Miller
# Website: http://devopsmachine.com/
# File: /usr/local/bin/set-primary-monitor-pantheon-greeter
#
# Set correct primary monitor for login screen when lightdm greeter starts up on Elementary OS.
#
@larahogan
larahogan / app-perf.md
Last active May 7, 2021 01:18
Native app performance metrics

Native app performance metrics

This is a draft list of what we're thinking about measuring in Etsy's native apps.

Currently we're looking at how to measure these things with Espresso and Kif (or if each metric is even possible to measure in an automated way). We'd like to build internal dashboards and alerts around regressions in these metrics using automated tests. In the future, we'll want to measure most of these things with RUM too.

Overall app metrics

  • App launch time - how long does it take between tapping the icon and being able to interact with the app?
  • Time to complete critical flows - using automated testing, how long does it take a user to finish the checkout flow, etc.?
  • Battery usage, including radio usage and GPS usage
  • Peak memory allocation
@gaearon
gaearon / combining.js
Created June 3, 2015 18:03
Combining Stateless Stores
// ------------
// counterStore.js
// ------------
import {
INCREMENT_COUNTER,
DECREMENT_COUNTER
} from '../constants/ActionTypes';
const initialState = { counter: 0 };
@acdlite
acdlite / flux.js
Last active October 7, 2021 17:19
A Redux-like Flux implementation in <75 lines of code
/**
* Basic proof of concept.
* - Hot reloadable
* - Stateless stores
* - Stores and action creators interoperable with Redux.
*/
import React, { Component } from 'react';
export default function dispatch(store, atom, action) {
@JonoB
JonoB / gist:6637861
Created September 20, 2013 13:49
Laravel Base Model
<?php namespace Tmb;
use Illuminate\Database\Eloquent\Model as Eloquent;
use Illuminate\Validation\Validator;
class BaseModel extends Eloquent
{
/**
* Error message bag
@johanndt
johanndt / upgrade-postgres-9.3-to-9.5.md
Last active July 15, 2022 12:35 — forked from dideler/upgrade-postgres-9.3-to-9.4.md
Upgrading PostgreSQL from 9.3 to 9.5 on Ubuntu

TL;DR

Install Postgres 9.5, and then:

sudo pg_dropcluster 9.5 main --stop
sudo pg_upgradecluster 9.3 main
sudo pg_dropcluster 9.3 main
@ftvs
ftvs / PhonecallReceiver.java
Last active October 11, 2023 10:05
Detecting an incoming call coming to an Android device. Remember to set the appropriate permissions in AndroidManifest.xml as suggested in the Stackoverflow link. Usage example in comments. Source: Gabe Sechan http://stackoverflow.com/a/15564021/264619 Explanation: http://gabesechansoftware.com/is-the-phone-ringing/#more-8
package com.gabesechan.android.reusable.receivers;
import java.util.Date;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.telephony.TelephonyManager;
public abstract class PhonecallReceiver extends BroadcastReceiver {