The following are appendices from Optics By Example, a comprehensive guide to optics from beginner to advanced! If you like the content below, there's plenty more where that came from; pick up the book!
-- in response to https://twitter.com/chrislpenner/status/1221784005156036608 | |
-- | |
-- The goal is to mimic this Scala code, but in Haskell: | |
-- | |
-- > "spotify:user:123:playlist:456" match { | |
-- > case s"spotify:user:$userId:playlist:$playlistId" | |
-- > => ($userId, $playlistId) // ("123", "456") | |
-- > } | |
{-# LANGUAGE DeriveFunctor, LambdaCase, PatternSynonyms, QuasiQuotes, RankNTypes, TemplateHaskell, TypeOperators, ViewPatterns #-} | |
{-# OPTIONS -Wno-name-shadowing #-} |
use std::str; | |
fn main() { | |
// -- FROM: vec of chars -- | |
let src1: Vec<char> = vec!['j','{','"','i','m','m','y','"','}']; | |
// to String | |
let string1: String = src1.iter().collect::<String>(); | |
// to str | |
let str1: &str = &src1.iter().collect::<String>(); | |
// to vec of byte |
This gist demonstrates a trick I came up with which is defining
IsString
for Q (TExp a)
, where a
is lift
-able. This allows you
to write $$("...")
and have the string parsed at compile-time.
On GHC 9, you are able to write $$"..."
instead.
This offers a light-weight way to enforce compile-time constraints. It's
basically OverloadedStrings
with static checks. The inferred return type
const getSvgNamesForNodes = () => { | |
// this is guesswork. When Figma has two nodes with the same name (say, "Union"), | |
// it serialises them into SVG with names "Union" and "Union_2", but it's not | |
// clear which one becomes "Union" and which "Union_2". It is theorised that this | |
// is done in the same order that .findAll returns, so we make use of that. | |
// Figma might decide to change this at any time, of course. It would be much | |
// nicer if there were an SVG export option which also serialised getPluginData() | |
// data as data-* attributes in the output SVG, but there isn't, yet. | |
let names = {}; | |
let nameIndices = {}; |
import * as vscode from "vscode"; | |
import { initUsePackage, usePackage, configSet } from "vscode-use-package"; | |
import * as nav from "./nav"; | |
import * as js from "./js"; | |
import * as rust from "./rust"; | |
export function init(context: vscode.ExtensionContext) { | |
console.log(`HELLO FROM INIT SCRIPT`); |
{-# language TypeInType #-} | |
-- | Types which have PureScript equivalents | |
class ToPursTyCon a where | |
toPursTyCon :: Tagged a PursTypeConstructor | |
-- | The default instance uses 'G.Generic' and pattern matches on the | |
-- type's representation to create a PureScript type. | |
default toPursTyCon :: (G.Generic a, GenericToPursTyCon (G.Rep a)) => Tagged a PursTypeConstructor | |
toPursTyCon = retag $ genericToPursTyConWith @(G.Rep a) defaultPursTypeOptions |
let UserContext = React.createContext(); | |
class App extends React.Component { | |
state = { | |
user: null, | |
setUser: user => { | |
this.setState({ user }); | |
} | |
}; |
SSE3=1 SSSE3=1 SSE4_1=1 SAHF=1 AVX=1 FMA3=1 BMI1=1 BMI2=1 LZCNT=1 POPCNT=1 ATOM=0 | |
Synopsis: | |
shell [options] [--shell] [<file>...] | |
d8 [options] [-e <string>] [--shell] [[--module] <file>...] | |
-e execute a string in V8 | |
--shell run an interactive JavaScript shell | |
--module execute a file as a JavaScript module | |
Options: |
Generally, the Git proxy configuration depends on the Git Server Protocol you use. And there're two common protocols: SSH and HTTP/HTTPS. Both require a proxy setup already. In the following, I assume a SOCKS5 proxy set up on localhost:1080
. But it can also be a HTTP proxy. I'll talk about how to set up a SOCKS5 proxy later.
When you do git clone ssh://[user@]server/project.git
or git clone [user@]server:project.git
, you're using the SSH protocol. You need to configurate your SSH client to use a proxy. Add the following to your SSH config file, say ~/.ssh/config
:
ProxyCommand nc -x localhost:1080 %h %p