Skip to content

Instantly share code, notes, and snippets.

@parshap
parshap / node-modules-in-react-native.md
Last active November 15, 2023 11:15
Running Node Modules in React Native

Running Node Modules in React Native

How to use packages that depend on Node.js core modules in React Native.

See the [node-libs-react-native][node-libs-react-native] library as a convenience for implementing this method.

Node.js Core Modules

class Example {
@observable private _name;
private counter = 0;
@computed
get name(): string {
return this._name;
}
set name(value: string) {
@ttscoff
ttscoff / init.lua
Last active January 9, 2024 23:44
Hammerspoon config examples for hyper key
-- A global variable for the Hyper Mode
k = hs.hotkey.modal.new({}, "F17")
-- Trigger existing hyper key shortcuts
k:bind({}, 'm', nil, function() hs.eventtap.keyStroke({"cmd","alt","shift","ctrl"}, 'm') end)
-- OR build your own
launch = function(appname)
# GIT heart FZF
# -------------
is_in_git_repo() {
git rev-parse HEAD > /dev/null 2>&1
}
fzf-down() {
fzf --height 50% --min-height 20 --border --bind ctrl-/:toggle-preview "$@"
}
import { observable, computed } from 'mobx';
import { observer } from "mobx-react";
class BookList {
@observable books = []
@computed get readBooks(){
return this.books.filter(b => b.isRead);
}
loadBooks(){
setTimeout(() => {
@dznz
dznz / gist:64a34466f44d1a335e75
Created October 29, 2015 22:40
Extract the filename from a path in Excel or Google spreadsheet
=TRIM(RIGHT(SUBSTITUTE(A1,"/",REPT(" ",100)),99))
@nackjicholson
nackjicholson / injection-spec.js
Created April 26, 2015 02:27
Better tests, proxyquire vs injection vs mockless
var assert = require('assert')
var sinon = require('sinon')
var dependency = require('dependency')
var sut = require('./injection-sut')
describe('sut', function () {
var methodStub
beforeEach(function () {
methodStub = sinon.stub(dependency, 'method')
That’s one of the real strengths of Docker: the ability to go back to a previous commit. The secret is simply to docker tag the image you want.
Here’s an example. In this example, I first installed ping, then committed, then installed curl, and committed that. Then I rolled back the image to contain only ping:
$ docker history imagename
IMAGE CREATED CREATED BY SIZE
f770fc671f11 12 seconds ago apt-get install -y curl 21.3 MB
28445c70c2b3 39 seconds ago apt-get install ping 11.57 MB
8dbd9e392a96 7 months ago 131.5 MB
@korya
korya / Subfolder to git repo.md
Last active December 16, 2023 10:29
Convert subfolder into Git submodule
@Neil-Smithline
Neil-Smithline / idletime.sh
Created March 18, 2012 15:33
Mac OS X Idle Time Shell Script
#!/bin/sh
# Get MacOSX idletime. Shamelessly stolen from http://bit.ly/yVhc5H
/usr/sbin/ioreg -c IOHIDSystem | /usr/bin/awk '/HIDIdleTime/ {print int($NF/1000000000); exit}'