Skip to content

Instantly share code, notes, and snippets.

@archgrove
archgrove / OGExportAllForLaTeX.scpt
Created May 10, 2012 15:09
Omnigraffle "Export all Canvases for LaTeX"
# Replace "search" with "replacement" in "input" (all text)
on replace_string(input, search, replacement)
set oldDelim to AppleScript's text item delimiters
set AppleScript's text item delimiters to search
set textItems to every text item of input
set AppleScript's text item delimiters to replacement
set res to textItems as string
set AppleScript's text item delimiters to oldDelim
return res
@cjohansen
cjohansen / gist:739589
Created December 13, 2010 20:55
Showing how to fake server requests with Sinon.JS and Jasmine
/*
Load Sinon.JS in the SpecRunner:
<script type="text/javascript" src="lib/jasmine-1.0.1/jasmine.js"></script>
<script type="text/javascript" src="lib/jasmine-1.0.1/jasmine-html.js"></script>
<script type="text/javascript" src="sinon-1.0.0.js"></script>
<script type="text/javascript" src="sinon-ie-1.0.0.js"></script>
http://cjohansen.no/sinon/
*/
@jamsesso
jamsesso / dev-server.js
Last active August 24, 2020 13:27
Webpack dev server with a better proxy (http-proxy-middleware)
var express = require('express');
var path = require('path');
var webpackConfig = require('./webpack.config');
var webpack = require('webpack');
var webpackDevMiddleware = require('webpack-dev-middleware');
var webpackHotMiddleware = require('webpack-hot-middleware');
var proxyMiddleware = require('http-proxy-middleware');
var devConfig = webpackConfig.devServer;
var app = express();
@tmatilai
tmatilai / Vagrantfile
Last active January 1, 2021 19:49
My global Vagrant configuration (~/.vagrant.d/Vagrantfile)
# URI of the local (caching) HTTP proxy
LOCAL_HTTP_PROXY = 'http://192.168.33.200:8123'
# Configures vagrant-cachier and vagrant-proxyconf.
# Should be called only on "local machine" providers.
def configure_caching(config)
if Vagrant.has_plugin?('vagrant-cachier')
config.cache.enable_nfs = true
config.cache.enable :gem
config.cache.enable :npm
@shaik2many
shaik2many / java-file-write-performance.java
Created November 7, 2014 17:31
java file write performance
/**
* http://stackoverflow.com/questions/1062113/fastest-way-to-write-huge-data-in-text-file-java
*
* I have to write huge data in text[csv] file. I used BufferedWriter to write the data and it
* took around 40 secs to write 174 mb of data. Is this the fastest speed java can offer?
* bufferedWriter = new BufferedWriter ( new FileWriter ( "fileName.csv" ) );
*
* You might try removing the BufferedWriter and just using the FileWriter directly. On a modern system
* there's a good chance you're just writing to the drive's cache memory anyway.
* It takes me in the range of 4-5 seconds to write 175MB (4 million strings) -- this is on a dual-core 2.4GHz Dell
@ms-tg
ms-tg / jdk8_optional_monad_laws.java
Created November 11, 2013 21:14
Does JDK8's Optional class satisfy the Monad laws? Yes, it does.
/**
* ```
* Does JDK8's Optional class satisfy the Monad laws?
* =================================================
* 1. Left identity: true
* 2. Right identity: true
* 3. Associativity: true
*
* Yes, it does.
* ```
@mathieuancelin
mathieuancelin / Lens.java
Last active March 7, 2023 02:23
Lenses with Java 8
package bar.foo.lenses;
import java.util.function.BiFunction;
import java.util.function.Function;
public class Lens<A, B> {
private final Function<A, B> getter;
private final BiFunction<A, B, A> setter;
@1natsu172
1natsu172 / .eslintrc
Last active July 5, 2023 10:23
My airbnb based ESLint config for "typescript-eslint" with React & prettier
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json",
"tsconfigRootDir": "."
},
"env": {
"browser": true,
"jest/globals": true
},
@twhitbeck
twhitbeck / MSWExample.stories.tsx
Created October 14, 2022 10:07
An example of using `msw` with ladle
import { setupWorker, rest } from "msw";
export const ExampleStory = () => {
...
};
ExampleStory.decorators = [
(Story) => {
const [ready, setReady] = React.useState(false);