Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.
$ python -m SimpleHTTPServer 8000
Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.
$ python -m SimpleHTTPServer 8000
// === Arrays | |
var [a, b] = [1, 2]; | |
console.log(a, b); | |
//=> 1 2 | |
// Use from functions, only select from pattern | |
var foo = () => [1, 2, 3]; |
# Here's a contrived example of a LEFT JOIN using ARel. This is an example of | |
# the mechanics, not a real-world use case. | |
# NOTE: In the gist comments, @ozydingo linked their general-purpose ActiveRecord | |
# extension that works for any named association. That's what I really wanted! | |
# Go use that! Go: https://gist.github.com/ozydingo/70de96ad57ab69003446 | |
# == DEFINITIONS | |
# - A Taxi is a car for hire. A taxi has_many :passengers. | |
# - A Passenger records one person riding in one taxi one time. It belongs_to :taxi. |
require 'active_record' | |
require 'arel' | |
# Ruby-like syntax in AR conditions using the underlying Arel layer (Rails >= 3.0). | |
# | |
# What you would usually write like this: | |
# | |
# User.where(["users.created_at > ? AND users.name LIKE ?", Date.yesterday, "Mary"]) | |
# | |
# can now be written like this (note those parentheses required by the operators precedences): |
#!/usr/bin/env python3 | |
# docs: https://grafana.com/docs/loki/latest/api/#post-lokiapiv1push | |
import requests | |
import time | |
# variables | |
LOKI_USERNAME="x" | |
LOKI_PASSWORD="x" | |
LOKI_ENDPOINT="https://loki-api.example.com/loki/api/v1/push" |
Install the React Developer Tools Chrome Extension.
Go to the egghead website, i.e. Getting Started with Redux
Click View -> Developer -> Javascript Console
, then the React
tab, then the <NextUpLessonList ...>
tag.
Click back to the Console
tab, then run:
import qs from "qs"; | |
import { ZodSchema } from "zod"; | |
const parseObjectPrimitives = (obj: Record<string, any>): any => { | |
return Object.fromEntries( | |
Object.entries(obj).map(([k, v]) => { | |
if (typeof v === "object") return [k, parseObjectPrimitives(v)]; | |
if (!isNaN(parseFloat(v))) return [k, parseFloat(v)]; | |
if (v === "true") return [k, true]; | |
if (v === "false") return [k, false]; |
This Gist provides some code examples of how to implement WebSocket stream handling using a Redux middleware. Please be aware that this is only provided as an example and that critical things like exception handling have not been implemented.
A more complete version has been packaged, tested, and is available on GitHub as redux-websocket. This library has also been published to npm at @giantmachines/redux-websocket
.
This module represents the foundation of the middleware and implements the ideas presented above. The exported function is used during the creation of the Redux store (see the following snippet).
What happens if you tell GitHub it's JSON
{
"hello": "world" // I want my comments!
}
Just tell GitHub it's JavaScript
{
# rotate | |
ffmpeg -i input.mp4 -map_metadata 0 -c copy -metadata:s:v rotate="180" output.mp4 | |
# extract subs from mp4 | |
# https://superuser.com/questions/393762/how-to-extract-subtitles-from-mp4-and-mkv-movies | |
ffmpeg -i video.mp4 subtitle.srt | |
# convert audio (using vbr) | |
ffmpeg -i input.mkv -c:a libopus -b:a 256k -vbr 1 -af "channelmap=channel_layout=5.1" output.mkv |