Skip to content

Instantly share code, notes, and snippets.

View SleeplessByte's full-sized avatar
💎
💎 💎 💎

Derk-Jan Karrenbeld SleeplessByte

💎
💎 💎 💎
View GitHub Profile
@SleeplessByte
SleeplessByte / .gradle
Created January 24, 2015 23:51
Android Studio - How to gitignore your signing.
View .gradle
apply plugin: 'com.android.application'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile [...]
}
android {
// Add a gradle.properties to your root to make this workd:
@SleeplessByte
SleeplessByte / useColorScheme.ts
Created February 18, 2020 20:44
Hooks and Contexts to deal with react-native-appearance. Automatically updates and persists changes.
View useColorScheme.ts
import React, { useMemo } from "react";
import {
createContext,
useContext,
useState,
useEffect,
useCallback
} from "react";
import {
Appearance,
@SleeplessByte
SleeplessByte / contributions.md
Last active May 14, 2021 17:23
Exercism contributions
View contributions.md

I really don't like the notion where we look at commit counts (that's code style), line count (quantity/quality, and highly different per language) or even time investment (indication of efficiency, not effort), so I've only listed the projects and the additions and leave it up to managment to make some pragmatic choices for rewards.

This is a non-comprehensive list of things I think I contributed, which others can use as a basis for their own list.

Tooling I've written from scratch

@SleeplessByte
SleeplessByte / .gitattributes
Last active February 3, 2021 14:57
.gitattributes that will make development on Windows Great Again
View .gitattributes
# Handle line endings automatically for files detected as text
# and leave all files detected as binary untouched.
* text=auto
# Force the following filetypes to have unix eols, so Windows does not break them
*.* text eol=lf
# Windows forced line-endings
/.idea/* text eol=crlf
@SleeplessByte
SleeplessByte / aoc-2020-d16.rb
Last active December 17, 2020 00:19
Advent of Code 2020: Day 16 - Ticket Translation
View aoc-2020-d16.rb
rules, yours, nearby = File.read('input.txt').split(/\n\n/)
def ticket_values(nearby)
nearby.split("\n")[1..]
end
def category_values(rules)
rules.split("\n").each_with_object({}) do |line, categories|
next if line.empty?
@SleeplessByte
SleeplessByte / aoc-2020-d15.rb
Created December 15, 2020 16:36
Advent of Code 2020: Day 15 - Rambunctious Recitation
View aoc-2020-d15.rb
numbers = File.read('input.txt').chomp.split(',').map(&:to_i)
turns = numbers.dup
memory = Hash.new { [] }
numbers.each_with_index do |number, turn|
memory[number] = [turn]
puts "Turn #{turn + 1}: #{number}"
end
@SleeplessByte
SleeplessByte / aoc-2020-d14.rb
Last active December 14, 2020 21:21
Advent of Code 2020: Day 14 - Docking Data
View aoc-2020-d14.rb
require 'benchmark'
def mask_rjust(value, mask)
value.to_s(2).rjust(mask.length, "0")
end
def mask_from_line(maskline)
mask = maskline.chomp.split('mask = ').last
add = mask.tr('01X', '010').to_i(2)
sub = mask.tr('01X', '011').to_i(2)
@SleeplessByte
SleeplessByte / aoc-2020-d13.rb
Created December 13, 2020 23:22
Advent of Code 2020: Day 13 - Shuttle Search
View aoc-2020-d13.rb
require 'prime'
require 'benchmark'
source = 'input.txt'
timestamp, schedule_line = File.readlines(source)
schedule = schedule_line.split(',').map { |x| x.chomp }
busses = schedule
.each_with_index
@SleeplessByte
SleeplessByte / aoc-2020-d12.rb
Last active December 12, 2020 11:08
Advent of Code 2020: Day 12 - Rain Risk
View aoc-2020-d12.rb
require 'benchmark'
class Ship
attr_reader :position
def initialize
self.facing = 90
self.position = Position.new(0, 0)
self.waypoint = Waypoint.new
@SleeplessByte
SleeplessByte / aoc-2020-d11.rb
Last active December 11, 2020 06:34
Advent of Code 2020: Day 11 - Seating System
View aoc-2020-d11.rb
require 'benchmark'
class Seat
def initialize(mark)
self.mark = mark
self.next_mark = mark
end
def valid?
mark != 'X'