Skip to content

Instantly share code, notes, and snippets.

Avatar
3 cups required

@greweb gre

3 cups required
View GitHub Profile
View recordHistory_gcal_cryptofinance.js
function recordHistory() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
// Toggle a cell that is used in one of a CRYPTOFINANCE formula to force-trigger a refresh
var r = ss.getSheetByName("folio").getRange("A30");
var unit = r.getValues()[0][0];
r.setValue(unit==='BTCEUR'?'BTC/EUR':'BTCEUR');
// accumulate history
var sheet = ss.getSheetByName("History");
View main.js
import React, { Component } from "react";
class Counter extends Component {
state = { count: 1 };
onClick = () => this.setState(({ count }) => ({ count: count + 1 }));
render() {
return (
<button onClick={this.onClick}>
{this.state.count}
</button>
@gre
gre / AspectRatioDiv.js
Created Mar 10, 2017
React AspectRatioDiv component, guarantees a div to keep a given ratio (assuming the layout don't change over time, otherwise call syncSize, or do a raf loop to call it)
View AspectRatioDiv.js
//@flow
import React, {
Component,
PropTypes,
} from "react";
const hasWindow = typeof window !== "undefined";
export default class AspectRatioDiv extends Component {
state: { width: ?number } = {
@gre
gre / ZZZ_output.js
Last active Jul 20, 2018
generate JavaScript WebGL API wrapper from the WebGL IDL. the output also contains flowtypes.
View ZZZ_output.js
//@flow
/* eslint-disable */
class ArrayBufferView {}
class WebGLObject {
_id: number;
constructor (id: number) {
this._id = id;
}
}
class WebGLBuffer extends WebGLObject {}
View dedup_list_of_all_gl_react_cookbook_example_gl_calls.txt
activeTexture
attachShader
bindAttribLocation
bindBuffer
bindFramebuffer
bindRenderbuffer
bindTexture
blendFunc
bufferData
checkFramebufferStatus
View index.js
document.write(`<link rel="stylesheet" href="https://rawgit.com/PrismJS/prism/gh-pages/themes/prism.css" />`);
var Prism = require('prismjs');
var code = [
"const c = `",
"// do something",
"float a = p.x * p.y;",
"",
"// do something else",
@gre
gre / webcam.js
Last active Nov 19, 2016
This is using an experimental incoming version of gl-react, stay tuned
View webcam.js
//@flow
import React, { Component } from "react";
import { Bus } from "gl-react";
import { Surface } from "gl-react-dom";
import colorScales from "./colorScales";
const shaders = Shaders.create({
colorify: {
frag: GLSL`
precision highp float;
@gre
gre / ReactNative.example.js
Created Sep 30, 2016
in React / React Native, simulate bad network (lag / error) to debug how your app behaves with images
View ReactNative.example.js
import React, {
Component,
} from "react";
import {
Image as RNImage,
View,
} from "react-native";
const debugImage =
__DEV__
View example.js
const { transform, execute } = require("./lib");
const ReactNativeWeb = require("react-native-web");
const {render} = require("react-dom");
const example = `
...jestsnapshotcodegoeshere
`;
const out = transform(example);
const node = execute(out, {
@gre
gre / README.md
Last active Jan 14, 2019
Standalone minimal version of Google Photos Albums list in order for you to share photos with family and with link to multiple shared google photos albums
View README.md

DWTFYW

Disclaimer:

  • no warranty this will work for you!
  • I'm not responsible of how you use this!
  • READ, VERIFY and TEST the CODE before using!