Skip to content

Instantly share code, notes, and snippets.

View biglovisa's full-sized avatar
🌍
Patch is hiring!

Lovisa Svallingson biglovisa

🌍
Patch is hiring!
View GitHub Profile
@carlosramireziii
carlosramireziii / attached_validator.rb
Last active April 10, 2024 11:11
A validator and RSpec matcher for requiring an attachment using Active Storage
class AttachedValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
record.errors.add(attribute, :attached, options) unless value.attached?
end
end
@martensonbj
martensonbj / readme-template.md
Created February 16, 2017 19:21
Personal project README template

Project Name & Pitch

Example:

TweetWorld

An application used to filter data form Twitter based on user preference, built with React, Redux, JavaScript, and CSS.

Project Status

(only necessary if incomplete)

@bignimbus
bignimbus / imagemagick-convert.sh
Last active April 24, 2020 21:03
Here are some of my pet ImageMagick commands.
# converts a png image to jpeg
# all transparent regions will be converted to white
convert -flatten source.png destination.jpg
@JoshCheek
JoshCheek / index.html
Created January 22, 2016 23:04
Playing with them colours!
<!DOCTYPE html>
<html>
<head>
<title>Smiley Face</title>
</head>
<body>
<canvas id="a" width="800" height="800">
This text is displayed if your browser does not support HTML5 Canvas.
</canvas>
@rrgayhart
rrgayhart / gist:cf5dcefdf3975598f491
Last active June 26, 2022 06:09
Adding Sinon to WebPack

Adding Sinon to WebPack

  • Open your project (if you're using WebPack, obviously)

  • npm install sinon --save-dev

  • You should now have Sinon in your node modules and listed in your package.json file

  • In your tests, require Sinon: var sinon = require('sinon');

@JoshCheek
JoshCheek / js.rb
Created December 2, 2015 01:11
Example of how JS async works for a student
class JavaScript
def initialize
@work = []
@background_worker_count = 0
end
def run(&code)
@work << code
while @work.any? || @background_worker_count > 0
instance_eval &@work.shift if @work.any?
@JoshCheek
JoshCheek / love.rb
Last active October 31, 2015 19:05
Love.rb
_ \
, __ , # (C) Josh Cheek
*,_ = # 2015
def __ ___ , # Inspiration
*__, **_ # Is
putc ___ # Obviously
end, def _ *_, # Yusuke
**__ # Endoh
_. #
map {|_ ;__ # And
@JoshCheek
JoshCheek / 15_ways_to_make_a_linked_list.rb
Created July 21, 2015 18:44
15 ways to make a linked list
# ----- Common Linked List Methods -----
def add_to_front(list, data)
build_list(data, list)
end
def add_to_back(list, data)
return build_list(data, empty_list) if empty?(list)
new_tail = add_to_back(tail(list), data)
build_list(head(list), new_tail)