Skip to content

Instantly share code, notes, and snippets.

View valscion's full-sized avatar

Vesa Laakso valscion

View GitHub Profile
@valscion
valscion / BodyScrollPreventer.js
Created January 8, 2017 15:39
Preventing scroll for modals
/* @flow */
import React, { Component } from 'react';
// $FlowFixMe
import $ from 'jquery';
// Disables body element scrolling on touch past the element passed in.
// This is the only way to stop the body element from scrolling on Mobile Safari
function preventOverscroll(el: HTMLElement) {
// If the element is not scrollable, the body may scroll instead.
@valscion
valscion / App.test.js.patch
Last active November 17, 2016 14:13
#create-react-app/1052 example
diff --git a/packages/react-scripts/template/src/App.test.js b/packages/react-scripts/template/src/App.test.js
index b84af98..8cefbcf 100644
--- a/packages/react-scripts/template/src/App.test.js
+++ b/packages/react-scripts/template/src/App.test.js
@@ -3,6 +3,12 @@ import ReactDOM from 'react-dom';
import App from './App';
it('renders without crashing', () => {
+ const fn = ({ a, ...otherProps }) => otherProps;
+
@valscion
valscion / Datepicker_fun.user.js
Created November 15, 2016 11:45
Inject date to staff CSV page
// ==UserScript==
// @name Datepicker for Venuu CSV exports
// @include https://staging.venuu.fi/staff/csv_exports*
// @include https://venuu.fi/staff/csv_exports*
// @require https://code.jquery.com/ui/1.12.1/jquery-ui.min.js
// @grant none
// ==/UserScript==
//--- Date picker needs additional CSS
document.addEventListener('DOMContentLoaded', function () {
// Add jQuery UI CSS to page
$ npm install -g flow-typed@2.0.0-beta.5
-
> nodegit@0.13.2 install /Users/vesa/.nvm/versions/node/v4.4.0/lib/node_modules/flow-typed/node_modules/nodegit
> node lifecycleScripts/install
[nodegit] Fetching binary from S3.
[nodegit] Failed to install prebuilt binary:
{ [Error: Command failed: /bin/sh -c "/Users/vesa/.nvm/versions/node/v4.4.0/lib/node_modules/flow-typed/node_modules/nodegit/node_modules/.bin/node-pre-gyp" install --fallback-to-build=false
module.js:327
throw err;
@valscion
valscion / I18nRuntimePlugin.js
Created February 21, 2016 11:33
Venuu I18n Webpack integration
var ConstDependency = require('webpack/lib/dependencies/ConstDependency');
var NullFactory = require('webpack/lib/NullFactory');
var _ = require('lodash');
function I18nRuntimePlugin(options) {
options = options || {};
this.functionNames = options.functionNames || ['I18n.t', 'I18n.translate'];
this.translationsPlaceholder = options.translationsPlaceholder || 'I18N_RUNTIME_TRANSLATIONS';
this.fullTranslations = options.fullTranslations || {};
}
@valscion
valscion / MyComponent.jsx
Last active August 29, 2015 14:24
An example of redux reducer returning a function in the state
import { connect } from 'redux/react';
import { ActionTypes } from 'constants/myConstants';
const { CHANGE_STATUS } = ActionTypes;
@connect(reduxState => ({
// Query for specific action
statusIsLoading: reduxState.loading.isLoading(ActionTypes.CHANGE_STATUS),
// Query for any action
isLoading: reduxState.loading.isLoading()
@valscion
valscion / mysql2sqlite.sh
Created May 5, 2014 14:04
mysql2sqlite.sh improved
#!/usr/bin/env bash
#
# mysql2sqlite.sh
# vqv
#
# A kludge for converting the MYSQL dump provided by http://www.baseball-databank.org/
# into a SQLITE3 compatible dump
#
# EXAMPLE USAGE: ./mysql2sqlite.sh BDB-sql-2008-03-28.sql | sqlite3 baseball.db
#
@valscion
valscion / example_event.json
Created March 1, 2014 15:38
Example data for new Ilmomasiina
{
"event": {
"id": 1,
"name": "Sukulaissitsit",
"description": "Tervetuloa sukulaissitseille! ...",
"image": "http://www.example.com/lolwut.jpg", // Optional
"event_date": {
"date": "2014-02-28",
"time": "17:00+0300" // Optional
},
@valscion
valscion / media.json
Created March 7, 2012 07:56
Sergei - media-JSON
{
"skenet": {
"verstas": {
// "kuva"-listan kuvat haetaan automaattisesti kansiosta media/skenet/verstas,
// eli "ulkokuva.png" on oikeasti media/skenet/verstas/ulkokuva.png
"kuva": ["ulkokuva.png", "verstas.png"],
"info": "Tämä on autotalli"
},
"takapiha": {
@valscion
valscion / raycast_testi.CB
Created January 9, 2012 19:35
CB raycast collision
ChDir "C:\Program Files (x86)\CoolBasic"
// CBRAYCASTER
// -----------
// Esimerkin näppäimet:
// - Enter: Vaihtaa debug-tilaa
// - Välilyönti: Generoi kartan uudelleen
// - Hiiren rulla: Muuttaa kartan satunnaisuuden astetta
// - WASD: Liikuttaa objektia
// - Nuolet vasen-oikea: Kääntää objektia