Skip to content

Instantly share code, notes, and snippets.

View duckinator's full-sized avatar

Ellen Marie Dash duckinator

View GitHub Profile
#ifndef _UNISTD_H
#define _UNISTD_H
/* ok, this may be a joke, but I'm working on it */
#define _POSIX_VERSION 198808L
#define _POSIX_CHOWN_RESTRICTED /* only root can do a chown (I think..) */
/* #define _POSIX_NO_TRUNC*/ /* pathname truncation (but see in kernel) */
#define _POSIX_VDISABLE '\0' /* character to disable things like ^C */
/*#define _POSIX_SAVED_IDS */ /* we'll get to this yet */
@duckinator
duckinator / gmail.rb
Created April 23, 2011 15:53
script to fetch emails from gmail, without marking them as read
require 'net/imap'
require 'highline/import'
# Get username and password from console, via highline
username = ask('Username: ')
password = ask('Password: ') {|q| q.echo = false }
messages = {} # Because messages[7239]=... makes an ugly array
imap = Net::IMAP.new('imap.gmail.com', 993, true) # Connect to server
@duckinator
duckinator / gist:9205026
Last active September 7, 2022 08:18
Some quick explanations about when return is unnecessary in Ruby, as well as the guard pattern.

Ruby has implicit returns. This means that if a return is the last expression in a path of execution, there's no need for the return keyword.

Worth noting is that return's default argument is nil, which is a falsey value.

def foo
  do_stuff
  return
end
link-manager> import file_of_urls.txt
3 URLs found. Continue? [Y/n] y
----
NAME: Example Domain
LINK: https://example.com
TAGS: (None)
Example Domain
We couldn’t find that file to show.
.
|-- Aho - Compilers - Principles, Techniques, and Tools 2e.pdf
|-- ai
| |-- A Field Guide to Genetic Programming.pdf
| |-- Brief Introduction to Educational Implications of Artificial Intelligence.pdf
| |-- Computational-Linguistics.pdf
| |-- Global Optimization Algorithms Theory and Application.pdf
| |-- Machine Learning, Neural and Statistical Classification.pdf
| |-- Machine Learning.pdf
| `-- Neural Networks - A Systematic Introduction.pdf
.
├── Aho - Compilers - Principles, Techniques, and Tools 2e.pdf
├── ai
│   ├── A Field Guide to Genetic Programming.pdf
│   ├── Brief Introduction to Educational Implications of Artificial Intelligence.pdf
│   ├── Computational-Linguistics.pdf
│   ├── Global Optimization Algorithms Theory and Application.pdf
│   ├── Machine Learning, Neural and Statistical Classification.pdf
│   ├── Machine Learning.pdf
│   └── Neural Networks - A Systematic Introduction.pdf
@duckinator
duckinator / Error.gd
Last active April 15, 2020 15:23
Godot script to allow getting (more) friendly messages for errors.
# Generated by generate_error.sh
extends Node
func print_info(err):
printerr(info(err))
print_stack()
func name(err):
var error_names = {}
~/test$ printf " a\n b\n c\n"
a
b
c
~/test$ printf " a\n b\n c\n" | python3 -m textwrap-tool dedent
a
b
c
~/test$ printf " a\n b\n c\n" | python3 -m textwrap-tool indent '....'
#!/usr/bin/env python3
from pathlib import Path
import pep517.build
import sys
import textwrap
# quick-and-dirty pep517 wrapper that handles projects without a pyproject.toml.
# Released under public domain, CC0, or MIT license, whichever you prefer.