Skip to content

Instantly share code, notes, and snippets.

@worldsayshi
worldsayshi / ReactIFrame.jsx
Last active May 10, 2016 13:35
Reactive iframe with React
import React from 'react';
/*
Reactive iframe - Usage:
<Iframe html={myPlainTextHtml} />
Or if using the safer alternative:
<Iframe>
<div>hello world</div>
</Iframe>

For anyone working iteratively using webpack --watch: First do npm install node-notifier --save-dev and then put this into webpack.config.js:

const notifier = require('node-notifier');
  ...
  plugins: [
    function() {
      this.plugin("done", function(stats) {
          if (stats.hasErrors()) {
            notifier.notify('Error');
 } else {
@worldsayshi
worldsayshi / 50-synaptics.conf
Created March 18, 2016 13:43
Fixing Mac-like touch settings on Ubuntu laptop with somewhat mac-like touchpad
Section "InputClass"
Identifier "touchpad catchall"
Driver "synaptics"
MatchIsTouchpad "on"
# This option is recommend on all Linux systems using evdev, but cannot be
# enabled by default. See the following link for details:
# http://who-t.blogspot.com/2010/11/how-to-ignore-configuration-errors.html
MatchDevicePath "/dev/input/event*"
Option "SoftButtonAreas" "0 0 0 0 0 0 0 0"
Option "VertScrollDelta" "-30
@worldsayshi
worldsayshi / package.json
Last active January 5, 2016 17:08
Browserify es6 and react example build/watch script.
{
"name": "redux-browserify-es6-example",
"main": "js/index.js",
"scripts": {
"test": "mocha --require babel-core/register",
"test:watch": "npm test -- --watch"
},
"dependencies": {
"expect": "^1.13.4",
"express": "^4.13.3",
@worldsayshi
worldsayshi / Label.hs
Last active August 29, 2015 14:07
How to create lenses for Algebraic Data Types with fclabels
{-# LANGUAGE
TemplateHaskell
#-}
module Label where
import Data.Label.Partial
import Data.Label.Base
import Data.Label.Derive
data Foo a b c = A a
| B b
@worldsayshi
worldsayshi / Templ1.hs
Last active August 29, 2015 14:07
Hello world inspection of haskell data types with template haskell
{-# LANGUAGE TemplateHaskell #-}
module Templ1 where
import Language.Haskell.TH
import Templ2
data Person = P {
name :: String,
age :: Integer
}
@worldsayshi
worldsayshi / list_today.py
Last active November 24, 2016 12:30
Put this script in your working dir and run it at the end of the day to remind you what you've done (+ some other git useful commands)
#!/usr/bin/python
import os, fnmatch
# Some useful git commands to choose from:
reposNotCommited = 'git --no-pager log --branches --not --remotes --simplify-by-decoration --decorate --oneline'
logEntriesToday = 'git --no-pager log --since="6am"'
logEntriesLastSemester = 'git --no-pager log --since="2014-01-01" --until="2014-06-30" --oneline --author="Jon Doe"'
logEntriesThisWeek = 'git --no-pager log --since="last sunday"'
@worldsayshi
worldsayshi / DynLoad.hs
Last active February 25, 2022 15:01 — forked from jhartikainen/DynLoad.hs
Example for loading Haskell source code dynamically using the GHC api
-----------------------------------------------------------------------------
-- | Example for loading Haskell source code dynamically using the GHC api
-- Tested on ghc 7.4.2
--
-- Useful links:
-- GHC api:
-- http://www.haskell.org/ghc/docs/latest/html/libraries/ghc/GHC.html
-- Wiki:
-- http://www.haskell.org/haskellwiki/GHC/As_a_library
-----------------------------------------------------------------------------
{-# LANGUAGE ScopedTypeVariables #-}
module Blog.DynLoad (
loadSourceGhc,
execFnGhc
) where
{-
Source:
http://codeutopia.net/blog/2011/08/20/adventures-in-haskell-dynamic-loading-and-compiling-of-modules/
https://gist.github.com/jhartikainen/1158986
@worldsayshi
worldsayshi / mergeRepos.md
Last active December 25, 2015 04:09
How to merge git repos into a parent repo while maintaining history and using only "conventional git commands"

How to merge git repos with history with conventional git commands only

Clone what is to become child projects

git clone git:path/to/repo1
git clone git:path/to/repo2

Move repo contents one level down. By default this should not move hidden files. We don't want to move the .git folder so that is good.