Skip to content

Instantly share code, notes, and snippets.

@RoryKelly
RoryKelly / App.js
Last active January 24, 2022 05:58
App to demonstrate problems using react navigation with react redux
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React from 'react';
import {combineReducers, createStore} from 'redux'
import {Button, Text, View} from "react-native";
import {addNavigationHelpers, NavigationActions, StackNavigator} from "react-navigation";
@viperwarp
viperwarp / ReactNativeJson.java
Created February 24, 2016 03:02
React-Native Module, ReadableMap/Array to Java JSON objects
private static WritableMap convertJsonToMap(JSONObject jsonObject) throws JSONException {
WritableMap map = new WritableNativeMap();
Iterator<String> iterator = jsonObject.keys();
while (iterator.hasNext()) {
String key = iterator.next();
Object value = jsonObject.get(key);
if (value instanceof JSONObject) {
map.putMap(key, convertJsonToMap((JSONObject) value));
} else if (value instanceof JSONArray) {
┐┌┐┌┐
┘└┘└┘\ₒ/
┐┌┐┌┐ ∕ Friday
┘└┘└┘ノ)
┐┌┐┌┐ deploy,
┘└┘└┘
┐┌┐┌┐ good
┘└┘└┘
┐┌┐┌┐ luck!
│││││
@alexandre
alexandre / word_counter.py
Last active August 29, 2015 14:08
word counter
from itertools import groupby
def word_counter(*words):
'''Write a Python program that inputs a list of words, separated by white-
space, and outputs how many times each word appears in the list.
'''
return {word: len(list(word_group)) for word, word_group in
groupby(sorted(words), key=lambda x: x)}
@alexandre
alexandre / virtualenv.md
Last active August 26, 2016 18:18
Apenas uma receita de bolo para utilizar virtualenvwrapper em uma distribuição GNU/Linux...

Por que usar?

Com o virtualenv, nós temos um ambiente isolado para cada projeto. E com isso, podemos ter diversas versões diferentes, seja do Python ou do pacote (e.g. Flask). E você precisa instalar o virtualenv apenas para uma versão do Python, já que pode especificar qual versão o seu projeto (ambiente virtual) utilizará. =]

Mas por que o virtualenvwrapper?

Ele facilita bastante tanto a criação quando o acesso ao seu projeto:

  • Ao criar o projeto ele já ativa o seu ambiente virtual;
  • A função workon facilita bastante para acessar o seu "venv" de qualquer diretório
@cassiozen
cassiozen / NeuralNetwork.lua
Created July 17, 2014 20:05
Lua Neural Network
ACTIVATION_RESPONSE = 1
NeuralNetwork = {
transfer = function( x) return 1 / (1 + math.exp(-x / ACTIVATION_RESPONSE)) end --This is the Transfer function (in this case a sigmoid)
}
@alexfu
alexfu / DividerItemDecoration.java
Last active February 9, 2023 05:09
An ItemDecoration that draws dividers between items. Pulled from Android support demos.
/*
* Copyright (C) 2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
#!/bin/bash
baseDirs=( /d/Git/ /d/Projects/ )
let i=1
echo
echo "Pulling git repositories..."
echo
for baseDir in "${baseDirs[@]}"; do
cd $baseDir
echo "$((i++)) - Base directory '$baseDir'"
#!/usr/bin/env python
"""
Auto Cookie Clicker by foota, 2013.09.21
ref. http://orteil.dashnet.org/cookieclicker/
"""
import sys, os, time, threading
from pymouse import PyMouse
import ImageGrab
@impressiver
impressiver / raven-config.html
Last active October 26, 2024 15:03
Raven.js configuration for logging JavaScript exceptions to Sentry (https://getsentry.com/). Without the added ignore options, you'll quickly find yourself swamped with unactionable exceptions due to shoddy browser plugins and 3rd party script errors.
<!-- Raven.js Config -->
<script src="{{ JS_PATH }}/lib/raven.js" type="text/javascript"></script>
<script type="text/javascript">
// Ignore list based off: https://gist.github.com/1878283
var ravenOptions = {
// Will cause a deprecation warning, but the demise of `ignoreErrors` is still under discussion.
// See: https://github.com/getsentry/raven-js/issues/73
ignoreErrors: [
// Random plugins/extensions
'top.GLOBALS',