Skip to content

Instantly share code, notes, and snippets.

View raineorshine's full-sized avatar

Raine Revere raineorshine

  • New York, NY
View GitHub Profile
@raineorshine
raineorshine / python-cheat-sheet.py
Created November 8, 2013 17:05
Python Cheat Sheet
# importing
import sha # import the the sha module
from animal import Animal # import the Animal class from animal.py
# unit testing
# http://docs.python.org/3/library/unittest.html
import unittest
class AnimalTest(unittest.TestCase):
@raineorshine
raineorshine / bash-cheatsheet.sh
Last active April 4, 2018 18:45
Bash Cheat Sheet
type git # get the type of any command. Great for
# seeing if a command exists.
ls -t # sort by time, newest first
ls -tr # sort by time, oldest first
grep -r "test" FILE_OR_DIR # recursive full text search
grep -i "test" FILE # case insensitive
grep -c "pattern" FILE # count
grep -n "pattern" # show line numbers
@VictorTaelin
VictorTaelin / ethereum_delayed_computations.md
Last active April 12, 2018 16:42
Make Ethereum massively scalable today with delayed computations

Make Ethereum massively scalable today with delayed computations

Suppose you're writing a contract which involves a huge amount of participants. As an example, think of an online, blockchain-based Trading-Card Game with tournaments. How would you program a playCard function? You might be thinking of something like this:

function playCard(uint player, uint card){
    ...
    else if (card == PROFESSOR_OAK){
        // shuffles the player's hand on his deck
 shuffleHand(player)
@raineorshine
raineorshine / assert-throw.js
Last active March 16, 2019 18:37
Asserting solidity throws in truffle tests.
it('should throw an error', cb => {
const result = aMethodThatRejects()
result.then(x => { cb('Expected error. Instead got ' + x) }))
result.catch(() => cb())
})
@danawoodman
danawoodman / 1-react-websockets-reflux.md
Last active September 15, 2021 14:48
Using WebSockets with Reflux and React

WebSockets + Reflux + React

Using WebSockets, React and Reflux together can be a beautiful thing, but the intial setup can be a bit of a pain. The below examples attempt to offer one (arguably enjoyable) way to use these tools together.

Overview

This trifect works well if you think of things like so:

  1. Reflux Store: The store fetches, updates and persists data. A store can be a list of items or a single item. Most of the times you reach for this.state in react should instead live within stores. Stores can listen to other stores as well as to events being fired.
  2. Reflux Actions: Actions are triggered by components when the component wants to change the state of the store. A store listens to actions and can listen to more than one set of actions.
@kopischke
kopischke / alias_completion.sh
Last active June 4, 2022 00:53
Automatically add completion functions for aliases
# Automatically add completion for all aliases to commands having completion functions
function alias_completion {
local namespace="alias_completion"
# parse function based completion definitions, where capture group 2 => function and 3 => trigger
local compl_regex='complete( +[^ ]+)* -F ([^ ]+) ("[^"]+"|[^ ]+)'
# parse alias definitions, where capture group 1 => trigger, 2 => command, 3 => command arguments
local alias_regex="alias ([^=]+)='(\"[^\"]+\"|[^ ]+)(( +[^ ]+)*)'"
# create array of function completion triggers, keeping multi-word triggers together
@raineorshine
raineorshine / mongo-cheat-sheet.js
Last active July 7, 2022 20:22
Cheat Sheet: MongoDB
/* COMMAND LINE */
mongod & // start mongo server on port 27017 by default
mongo mydb // launch mongo shell using the specified database
// importing & exporting
mongoimport -d mydb -c mycollection --jsonArray --file input.json
mongoimport -d mydb -c mycollection --headerline --type csv --file input.csv
mongoexport -d mydb -c mycollection --out output.json
/* MONGO SHELL */
@chriseth
chriseth / 0 README.md
Last active November 6, 2022 19:55
Formal verification for re-entrant Solidity contracts

This gist shows how formal conditions of Solidity smart contracts can be automatically verified even in the presence of potential re-entrant calls from other contracts.

Solidity already supports formal verification of some contracts that do not make calls to other contracts. This of course excludes any contract that transfers Ether or tokens.

The Solidity contract below models a crude crowdfunding contract that can hold Ether and some person can withdraw Ether according to their shares. It is missing the actual access control, but the point that wants to be made

@raineorshine
raineorshine / responsive.css
Last active November 19, 2022 06:08
Cheat Sheet: Responsive Design
@media all and (max-width: 1024px) {...}
@media all and (min-width: 800px) and (max-width: 1024px) {...}
@media not screen and (color) {...}
@media only screen and (orientation: portrait) {...}
@media all and (max-width: 420px) {
section, aside {
float: none;
width: auto;
}
@shawnbot
shawnbot / index.md
Last active August 23, 2023 10:18
Testing web pages with Xcode's iOS Simulator

Finding the Simulator

You can test with the iOS Simulator that comes with Xcode. Navigate to the Xcode app in the Finder, right click and select "Show Package Contents":

screen shot 2013-05-06 at 12 04 27 pm

Then navigate to Contents > Applications, and open the shortcut to "iPhone Simulator" (it may be called "iOS Simulator" depending on which version of Xcode you're running):

screen shot 2013-05-06 at 12 05 45 pm