Skip to content

Instantly share code, notes, and snippets.

@LostKobrakai
LostKobrakai / post.md
Last active April 7, 2020 20:07 — forked from nahtnam/post.md
Using Laravel-Mix with Phoenix

Introduction

Laravel-Mix is "an elegant wrapper around Webpack for the 80% use case". It has nothing to do with Elixir's Mix and does not require Laravel to work!

Set up

Create a new phoenix application with mix phx.new. You may choose to add the --no-brunch flag to stop brunch from being intiailized, but I personally prefer leaving that in and replacing brunch so that the folder structure is set up for me.

$ mix phx.new demo

Install Laravel-Mix

@tashian
tashian / README.md
Last active December 4, 2020 17:52
Just-in-time label printing on the Zebra ZP450 using node.js + Easypost + Pusher + cups

This is the script we use at yerdle to print labels from our Rails backend to our Zebra ZP450 printer.

the Zebra

See this blog post for the whole story.

@euank
euank / README.md
Last active July 11, 2021 02:54
Fix chrome's console.log 'TypeError: Illegal invocation'

Chrome exhibits behavior different from firefox (and other javascript environments) in that console.log requires "this" to be console. This issue is discussed here.

Simple failing code is

var helloWorld = function(callback) { 
  callback("Hello World"); 
}; 
helloWorld(console.log);

The included snippet makes failing code function correctly without any other changes required. It just has to be run before any console.logs. Similar code can be written for console.info and so on.

@hl
hl / context.ex
Last active August 28, 2021 04:55
defmodule Context do
@moduledoc false
defmacro __using__(opts) do
repo = Keyword.fetch!(opts, :repo)
quote do
import Context, only: [context: 1, context: 2]
Module.put_attribute(__MODULE__, :__repo__, unquote(repo))
@tobitailor
tobitailor / get_barcode_from_image.js
Created June 1, 2010 19:33
Barcode recognition with JavaScript - Demo: http://bit.ly/djvUoy
/*
* Copyright (c) 2010 Tobias Schneider
* This script is freely distributable under the terms of the MIT license.
*/
(function(){
var UPC_SET = {
"3211": '0',
"2221": '1',
"2122": '2',
@PizzaBrandon
PizzaBrandon / jquery.waituntilexists.js
Last active August 24, 2023 14:23 — forked from buu700/jquery.waituntilexists.js
Updated waitUntilExists plugin
;(function ($, window) {
var intervals = {};
var removeListener = function(selector) {
if (intervals[selector]) {
window.clearInterval(intervals[selector]);
intervals[selector] = null;
}
@fightingtheboss
fightingtheboss / configuration.yml
Last active September 15, 2023 07:29
An Amazon Elastic Beanstalk configuration file for a Meteor project. This file needs to be saved in the .ebconfiguration/ directory at the root of your project. Deployed with `git aws.push`. Replace MONGO_URL with the URL to your MongoDB instance (I use MongoHQ).
packages:
yum:
git: []
files:
/opt/elasticbeanstalk/hooks/appdeploy/pre/51install_meteor.sh:
mode: "000755"
user: root
group: root
encoding: plain
@ak4zh
ak4zh / accounting.sql
Last active October 21, 2023 04:03 — forked from NYKevin/accounting.sql
Basic double-entry bookkeeping system, for PostgreSQL.
CREATE TABLE account_groups
(
id bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 9223372036854775807 CACHE 1 ),
name text COLLATE pg_catalog."default" NOT NULL,
account_group_id bigint,
CONSTRAINT account_types_pkey PRIMARY KEY (id),
CONSTRAINT account_groups_account_group_id_fkey FOREIGN KEY (account_group_id)
REFERENCES public.account_groups (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION,
@ejpcmac
ejpcmac / setup
Created September 28, 2018 20:39
Setup script for Phoenix projects using Nix and PostgreSQL
#!/bin/sh
echo
if [ ! -d "deps" ] || [ ! "$(ls -A deps)" ]; then
printf "\e[32m=> Fetching dependencies and building the application...\e[0m\n\n"
echo "+ mix do deps.get, compile --verbose"
mix do deps.get, compile --verbose
echo
fi
@yang-wei
yang-wei / destructuring.md
Last active February 20, 2024 04:40
Elm Destructuring (or Pattern Matching) cheatsheet

Should be work with 0.18

Destructuring(or pattern matching) is a way used to extract data from a data structure(tuple, list, record) that mirros the construction. Compare to other languages, Elm support much less destructuring but let's see what it got !

Tuple

myTuple = ("A", "B", "C")
myNestedTuple = ("A", "B", "C", ("X", "Y", "Z"))