Skip to content

Instantly share code, notes, and snippets.

@brigand
brigand / nickname.md
Created Mar 9, 2016
Freenode Setting Up Your Nickname
View nickname.md

What is the recommended way to set up my IRC nickname?

Please follow these steps to set up your nick and configure your client. Check off each step to make sure it's been done:

Select a permanent, master nickname. If the nickname you want is registered but has expired, just ask a staffer and in most cases, we will be happy to drop it for you.

Please avoid using the name of a community project or trademarked entity, to avoid conflicts. Write down your password and be sure to keep the sheet of paper in a safe place.

Register your IRC nick:

View .js
async function getUser(id) {
const p1 = getUserProfile(id);
const p2 = getUserSettings(id);
return {
profile: await p1,
settings: await p2,
};
}
View .js
class Peekable {
constructor(iter) {
this.iter = iter;
this.deck = [];
}
peek() {
if (!this.deck.length) {
this.deck = [this.iter.next()];
}
return this.deck[0];
View .js
import React, { useState } from "react";
import styled from "styled-components";
import { Button, Form } from 'semantic-ui-react'
const PatientDetails = () => {
const [details, setDetails] = useState({
name: "John Doe",
gender: "male",
age: 34,
referredBy: "self",
View fetchJson.js
// Based on: https://jsfiddle.net/t2g9ub43/1/
const fetchJson = async (url, { ...opts } = {}) => {
opts.headers = new Headers(opts.headers);
opts.headers.set('Accept', 'application/json');
return fetch(url, opts).then((resp) => {
const ct = resp.headers.get('content-type');
if (!ct || !ct.includes('application/json')) {
throw resp;
}
return resp.json().then((json) =>
View .rs
ErrorMime::JavaScript => format!(
"{pre}{json};\nlet css = {css_json};\n{code}\n{close}",
json = get_json(),
pre = "{ let error_json = ",
close = "}",
code = indoc::indoc!(r#"
const h = (tag, {style, ...props}, ...children) => {
const element = Object.assign(document.createElement(tag), props);
Object.assign(element.style, style);
for (const child of children) {
View .css
:root {
--fg: #d5ced9;
--bg: #23262e;
--red: #ee5d43;
--purple: #c74ded;
--yellow: #ffe66d;
--font: Arial, sans;
}
View http_error.rs
use std::fmt::Display;
use actix_web::{http::StatusCode, HttpResponse};
use serde_json::{json, to_string};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ErrorMime {
Json,
Html,
JavaScript,
View .js
const Foo = () => {
const foo = useSelector(selectFoo);
const [initial] = useState(foo);
useEffect(() => {
if (foo !== initial) {
console.log('foo');
}
}, [foo]);
View bad.rs
fn greet(name: &str) -> String {
if name.is_empty() {
// ..snip..
}
format!("Hello, {}", name)
}