<?php
function randHash($len=32)
{
return substr(md5(openssl_random_pseudo_bytes(20)),-$len);
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $(document).ready(function() { | |
| $("#blockchain button.set").click(function() { | |
| var value = parseInt($("#blockchain input.text").val(), 10); | |
| SimpleStorage.set(value); | |
| addToLog("#blockchain", "SimpleStorage.set(" + value + ")"); | |
| }); | |
| $("#blockchain button.get").click(function() { | |
| SimpleStorage.get().then(function(value) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { Component } from 'react'; | |
| import { TextInput } from 'react-native'; | |
| class Input extends Component { | |
| constructor(props) { | |
| super(props); | |
| this.state = { | |
| text: '' | |
| }; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /*! | |
| * | |
| * NEW VERSION AT https://github.com/c-kick/mobileConsole | |
| * | |
| * hnl.mobileConsole - javascript mobile console - v1.3.8 - 04/01/2021 | |
| * Adds html console to webpage. Especially useful for debugging JS on mobile devices. | |
| * Supports 'log', 'trace', 'info', 'warn', 'error', 'group', 'groupEnd', 'table', 'assert', 'clear' | |
| * Inspired by code by Jakub Fiala (https://gist.github.com/jakubfiala/8fe3461ab6508f46003d) | |
| * Licensed under the MIT license | |
| * |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * @param {object} scope - Object that all bound data will be attached to. | |
| */ | |
| function twoWayBind(scope) { | |
| // a list of all bindings used in the DOM | |
| // @example | |
| // { 'person.name': [<input type="text" data-bind="person.name"/>] } | |
| var bindings = {}; | |
| // each bindings old value to be compared for changes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // the main app file | |
| import express from "express"; | |
| import loadDb from "./loadDb"; // dummy middleware to load db (sets request.db) | |
| import authenticate from "./authentication"; // middleware for doing authentication | |
| import permit from "./authorization"; // middleware for checking if user's role is permitted to make request | |
| const app = express(), | |
| api = express.Router(); | |
| // first middleware will setup db connection |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Prototype that stores information about a given polynomial. | |
| function Polynomial(data) { | |
| // Support providing already existing Polynomials. | |
| this.polynomial = data instanceof Polynomial ? data.polynomial : data; | |
| } | |
| // Rank all coefficients in the polynomial and return the largest. | |
| Polynomial.prototype.getLargestCoefficient = function() { | |
| var re = /(\d+)/g, match, max = 0; | |
| while(match = re.exec(this.getPolynomial())) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title></title> | |
| <meta charset="utf-8" /> | |
| <script src="templating.js" type="text/javascript" charset="utf-8"></script> | |
| </head> | |
| <body> | |
| <template id=t> |
- Create an empty repo in BitBucket
git clone --bare [email protected]:user/repo.gitcd repo.gitgit push --mirror [email protected]:user/repo.git
createElement.js lets document.createElement use CSS selectors.
This is a pretty useful library for building out DOM elements. The whole thing runs on one regex and a for loop, so it’s plenty fast. The script is 300 bytes when compressed and gzipped. For 524 bytes (advanced), it includes nesting support and can generate entire DOM hierarchies, including text nodes.
document.createElement(); // generates <div />