Skip to content

Instantly share code, notes, and snippets.

Rust:

trait Interface {
    fn variable_we_need(&self) -> i32;
    fn use_variable() {
        do_something_with(self.variable_we_need());
    }
}

struct Implementer {
#[derive(Clone, Copy, Debug)]
enum Foo {
One,
Two,
}
impl Foo {
pub fn get_it(&self) -> &str {
match self {
Foo::One => "Doodoo",
@ohmree
ohmree / Makefile
Created December 24, 2019 00:09
Updated makefile
SRCS = main.c test.c
OBJS = $(SRCS:.c=.o)
EXENAME = test
CFLAGS = -Wall -Wpedantic -Wextra
all: debug
debug: CPPFLAGS += -DDEBUG
debug: CFLAGS += -Og -ggdb
debug: OUTDIR = out/debug
@ohmree
ohmree / Makefile
Last active December 23, 2019 22:05
Makefile trouble
SRCS = main.c test.c
OBJS = $(SRCS:.c=.o)
EXENAME = test
CFLAGS = -Wall -Wpedantic -Wextra
all: debug
# Debug settings
debug: CPPFLAGS += -DDEBUG
@ohmree
ohmree / recurse.rb
Last active November 5, 2019 14:54
# frozen_string_literal: true
def recurse(*more)
public_send(caller[0][/`.*'/][1..-2], *more)
end
def doit_helper(n, acc)
puts '*' * acc
recurse(n, acc+1) unless acc >= n
end
@ohmree
ohmree / befunge.rb
Created November 1, 2019 23:29
Problematic lines are 109-113
#!/usr/bin/env ruby
# frozen_string_literal: true
# A direction (y,x).
# The order follows the curses convention.
module Directions
RIGHT = { y: 0, x: 1 }.freeze
LEFT = { y: 0, x: -1 }.freeze
UP = { y: 1, x: 0 }.freeze
DOWN = { y: -1, x: 0 }.freeze
@ohmree
ohmree / befunge.rb
Last active November 1, 2019 21:24
HERE BE DRAGONS
#!/usr/bin/env ruby
# frozen_string_literal: true
# A direction (y,x).
# The order follows the curses convention.
module Directions
RIGHT = { y: 0, x: 1 }.freeze
LEFT = { y: 0, x: -1 }.freeze
UP = { y: 1, x: 0 }.freeze
DOWN = { y: -1, x: 0 }.freeze
@ohmree
ohmree / README.md
Created July 2, 2019 14:16
SCRIPT-8
#!/usr/bin/env ruby
require 'net/http'
require 'uri'
require 'json'
def vote(points)
poss = (1..9).to_s
s1, s2, s3, s4, s5 = ''
127.0.0.1 adclick.g.doublecklick.net
127.0.0.1 adeventtracker.spotify.com
127.0.0.1 adnxs.com
127.0.0.1 adnxs.comadplexmedia.adk2x.com
127.0.0.1 ads.spotify.com
127.0.0.1 ads-fa.spotify.com
127.0.0.1 analytics.spotify.com
127.0.0.1 audio2.spotify.com
127.0.0.1 audio-sp-sto.spotify.com
127.0.0.1 b.scorecardresearch.com