This file contains 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
-- Print contents of `tbl`, with indentation. | |
-- `indent` sets the initial level of indentation. | |
function tprint (tbl, indent) | |
if not indent then indent = 0 end | |
for k, v in pairs(tbl) do | |
formatting = string.rep(" ", indent) .. k .. ": " | |
if type(v) == "table" then | |
print(formatting) | |
tprint(v, indent+1) | |
elseif type(v) == 'boolean' then |
This file contains 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
// polyfill for event.offsetX/offsetY | |
// Firefox is the only browser that doesn't support it (IE has since 4) | |
(function() { | |
var evt = document.createEvent('MouseEvent'); | |
if (evt.offsetX === void 0) { | |
Object.defineProperties(MouseEvent.prototype, { | |
'offsetX': { | |
get: function() { | |
return this.layerX - this.target.offsetLeft; | |
} |
This file contains 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
export function useValidationHook(defaultItemState: Partial<KeywordAdItem>) { | |
// Allow partial a partial state to be used as the default/inital render. | |
let defaultState = {...DEFAULT_STATE}; | |
if (defaultItemState) { | |
Object.assign(defaultState.item, defaultItemState); | |
} | |
return useReducer((state: State, action: Action) => { | |
const { field, value } = action; | |
// Create a shallow copy of the old data and add/repace the new value. |
This file contains 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
/** | |
* Returns a new list, based on the previous list. | |
* Action describes how to create the new list. | |
* Shallow Copy | |
*/ | |
export function updateList(prevList: objectList, action: KeywordDispatchAction): objectList { | |
const { type, listIndex, data } = action; | |
// console.group('Action', type); | |
switch (type) { |
This file contains 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
// https://threejs.org/examples/webgl_lights_hemisphere.html | |
AFRAME.registerShader('gradient', { | |
schema: { | |
timeMsec: {type: 'time', is: 'uniform'}, | |
topColor: {type: 'color', is: 'uniform', default: '#0077ff'}, | |
bottomColor: {type: 'color', is: 'uniform', default: '#ffffff'}, | |
offset: {is: 'uniform', default: 33}, | |
exponent: {is: 'uniform', default: 0.6}, | |
}, | |
raw: false, |
This file contains 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
[ | |
["KIAA0141",-7.583179872,-0.03334987 ], | |
["EIF2AK1",-5.286158957,-0.038206876 ], | |
["URI1",-5.023483452,0.021195171 ], | |
["KIAA0947",-3.960840625,-0.389346067 ], | |
["TAZ",1.393157325,4.844039489 ], | |
["BRPF1",-3.668330762,-0.487446006 ], | |
["NELFE",-3.745420274,-0.603712746 ], | |
["GRSF1",-0.374317963,2.701531952 ], | |
["EIF4E2",-2.884958128,0.076901041 ], |
This file contains 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
[ | |
["A1BG__P1_h3_Top5",-0.02149393,0.322957496 ], | |
["A1BG__P2_h3_Top5",-0.948661145,0.087967564 ], | |
["A1CF__P1P2_h3_Top5",-0.787883758,-0.14937761 ], | |
["AAAS__P1P2_h4_Top5",1.458158366,0.303433169 ], | |
["AADAC__P1P2_h3_Top5",-0.153730471,0.021665742 ], | |
["AAMP__P1P2_h3_Top5",-2.900039485,-2.12058401 ], | |
["AASDH__P1P2_h4_Top5",1.241920441,0.019673949 ], | |
["AASDHPPT__P1P2_h3_Top5",-0.753686771,-0.3382019 ], | |
["ABCA12__P1P2_h3_Top5",-2.208185006,-0.121822514 ], |
This file contains 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
// From: https://cryptozombies.io/en/lesson/2/chapter/7 | |
contract SandwichFactory { | |
struct Sandwich { | |
string name; | |
string status; | |
} | |
Sandwich[] sandwiches; | |
function eatSandwich(uint _index) public { |
This file contains 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
pragma solidity ^0.4.0; | |
contract BOSGame { | |
struct Vote { | |
uint choice; | |
uint amount; | |
address owner; | |
} | |
mapping(address => Vote) playerVote; |
This file contains 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
pragma solidity ^0.4.24; | |
contract BankContract { | |
uint balane; | |
function deposit() public payable { | |
balane += msg.value; | |
} | |
function getBalance() public view returns (uint) { |
NewerOlder