Skip to content

Instantly share code, notes, and snippets.

View thaliaarchi's full-sized avatar

Thalia Archibald thaliaarchi

View GitHub Profile
@Kestrer
Kestrer / how-to-write-hygienic-macros.md
Created October 17, 2020 05:35
A guide on how to write hygienic Rust macros

How to Write Hygienic Rust Macros

Macro hygiene is the concept of macros that work in all contexts; they don't affect and aren't affected by anything around them. Ideally all macros would be fully hygienic, but there are lots of pitfalls and traps that make it all too easy to accidentally write unhygienic macros. This guide attempts to provide a comprehensive resource for writing the most hygienic macros.

Understanding the Module System

First, a little aside on the details of Rust's module system, and specifically paths; it is

@mildsunrise
mildsunrise / flatten.py
Last active September 17, 2021 12:39
Git history flattener https://twitter.com/mild_sunrise/status/1300181598306996224 (needs GitPython)
#!/usr/bin/env python3
from git import Repo, Commit
list_commits = lambda commits: '\n'.join(' {} {}'.format(n.hexsha[:8], n.message.splitlines()[0]) for n in commits)
repo = Repo.init('path to bare clone', bare=True, mkdir=False)
refs = repo.refs
# load whole graph
def visit_graph(roots, get_parents=lambda n: n.parents):
queue = list(roots)
I was drawn to programming, science, technology and science fiction
ever since I was a little kid. I can't say it's because I wanted to
make the world a better place. Not really. I was simply drawn to it
because I was drawn to it. Writing programs was fun. Figuring out how
nature works was fascinating. Science fiction felt like a grand
adventure.
Then I started a software company and poured every ounce of energy
into it. It failed. That hurt, but that part is ok. I made a lot of
mistakes and learned from them. This experience made me much, much
@Tomassito
Tomassito / download-file.js
Last active March 11, 2022 23:53 — forked from javilobo8/download-file.js
Download files with AJAX (axios)
axios({
url: 'http://localhost:5000/static/example.pdf',
method: 'GET',
responseType: 'blob', // important
}).then((response) => {
const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'file.pdf');
link.click();

Buttons

- import RaisedButton from 'material-ui/RiasedButton';
+ import Button from '@material-ui/core/Button';
- import ArrowBack from 'material-ui/svg-icons/navigation/arrow-back';
+ import ArrowBack from '@material-ui/icons/ArrowBack';
import { Link } from 'react-router-dom';

+ const styles = theme => ({
@Cartexius
Cartexius / install_gtest_ubuntu.md
Last active May 28, 2024 06:01
Install gtest in Ubuntu
@javilobo8
javilobo8 / download-file.js
Last active May 27, 2024 21:00
Download files with AJAX (axios)
axios({
url: 'http://localhost:5000/static/example.pdf',
method: 'GET',
responseType: 'blob', // important
}).then((response) => {
const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'file.pdf');
document.body.appendChild(link);
@KittyGiraudel
KittyGiraudel / SassMeister-input.scss
Last active November 22, 2016 11:19
Generated by SassMeister.com.
// ----
// Sass (v3.4.9)
// Compass (v1.0.1)
// ----
@function is-number($value) {
@return type-of($value) == 'number';
}
@function is-time($value) {
@guilherme
guilherme / gist:9604324
Last active May 17, 2024 14:09
Git pre-commit hook that detects if the developer forget to remove all the javascript console.log before commit.
#!/bin/sh
# Redirect output to stderr.
exec 1>&2
# enable user input
exec < /dev/tty
consoleregexp='console.log'
# CHECK
if test $(git diff --cached | grep $consoleregexp | wc -l) != 0
then
@tomykaira
tomykaira / partial_evaluation.md
Created July 22, 2012 14:55
Partial Evaluation, Futamura Projection And Their Applications

Partial Evaluation, Futamura Projection And Their Applications

What Partial Evaluation Is?

Partial evaluation means to fix some variables in the given code before execution. With a traditional implementation of a compiler or an interpreter, all variables are replaced with its value on each evaluation of that variable. This is because a variable can change at any timing. This is, however, not always true in actual applications. Almost all of large applications has setting variables and data