Skip to content

Instantly share code, notes, and snippets.

View persianturtle's full-sized avatar

Raphael Rafatpanah persianturtle

View GitHub Profile
@persianturtle
persianturtle / PhantomJS Screen Capture Script
Last active May 17, 2016 15:30
This script screenshots an array of URLs against an array of viewports after dynamically scrolling through the entire page using jQuery.
'use strict';
var page = require('webpage').create();
var loadInProgress = false;
var pageIndex = 0;
var viewportIndex = 0;
var urls = [
'https://google.com',
'https://kokorugs.com'
@persianturtle
persianturtle / ffmpeg
Last active January 10, 2017 16:31
List of useful ffmpeg commands
// Convert 4444/422 to WEBM
ffmpeg -i input.mov -c:v libvpx -qmin 0 -qmax 25 -crf 4 -b:v 1M -vf scale=1280:-2 -an -threads 0 output.webm
// Enable audio
ffmpeg -i input.mov -c:v libvpx -qmin 0 -qmax 25 -crf 4 -b:v 1M -threads 0 output.webm
// Convert 4444/422 to WEBM - Smaller bitrate
ffmpeg -i input.mov -c:v libvpx -qmin 0 -qmax 25 -crf 4 -b:v 256k -vf scale=1280:-2 -an -threads 0 output.webm
import React, { PropTypes, Component } from 'react';
import ApolloClient, { createNetworkInterface } from 'apollo-client';
import { ApolloProvider } from 'react-apollo';
import { Router, Route, IndexRoute, browserHistory } from 'react-router'
import './App.css';
import BookSearch from './BookSearch';
import BookDetails from './BookDetails';
import GoogleMap from 'google-map-react';
[%bs.raw {|require('./index.css')|}];
[@bs.module "./registerServiceWorker"] external register_service_worker : unit => unit = "default";
ReactDOMRe.renderToElementWithId(<App />, "root");
register_service_worker();
[%bs.raw {|require('./app.css')|}];
let component = ReasonReact.statelessComponent("App");
let make = _children => {
...component,
render: _self => <div className="App" />
};
[%bs.raw {|require('./app.css')|}];
type route =
| Home
| Page1
| Page2
| Page3;
type routeWithTitle = (route, string);
body {
margin: 0;
font-family: Helvetica, Arial, sans-serif;
}
h1, h2, h3 {
font-weight: normal;
}
img {
@persianturtle
persianturtle / app.re
Created February 13, 2018 02:24
Just the render field
render: self => {
let (route, title) = self.state.routeWithTitle;
<div
className=("App" ++ (self.state.nav.isOpen ? " overlay" : ""))
onClick=(_event => self.send(ToggleMenu(false)))>
<header>
<a
onClick=(
event => {
ReactEventRe.Mouse.stopPropagation(event);
@persianturtle
persianturtle / app.re
Created February 13, 2018 03:13
Just the reducer field (solution 1)
reducer: (action, state) =>
switch action {
| Navigate(_routeWithTitle) => ReasonReact.NoUpdate
| ToggleMenu(isOpen) =>
ReasonReact.UpdateWithSideEffects(
{
...state,
nav: {
isOpen: isOpen
}
@persianturtle
persianturtle / app.re
Created February 13, 2018 03:27
Just the reducer field (solution 2)
[@bs.val] [@bs.scope "document"] external documentElement : Dom.element = "";
...
reducer: (action, state) =>
switch action {
| Navigate(_routeWithTitle) => ReasonReact.NoUpdate
| ToggleMenu(isOpen) =>
ReasonReact.UpdateWithSideEffects(
{