Skip to content

Instantly share code, notes, and snippets.

View peagha's full-sized avatar

Philippe Hardardt peagha

View GitHub Profile
require 'ruby2d'
require 'delegate'
set(
title: 'arch sim',
background: 'blue',
width: 1500,
height: 1300
)
import 'dart:async';
import 'package:flutter/material.dart';
void main() => runApp(MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('AnimatedContainer Demo'),
),
body: Center(child: Highlight(child: Text('123123123122312312'))),
)));
@peagha
peagha / global_methods_ruby.rb
Last active September 26, 2018 14:14
How to create a global method without defining it in Object
# global method defined in Object
def pp1
'pp1!'
end
pp1 # => "pp1!"
Object.instance_methods.include?(:pp1) # => true
class PP1
def my_pp1
@peagha
peagha / anagram.rb
Last active February 6, 2018 22:16
Prime number anagram implementation
require 'prime'
require 'minitest/autorun'
class Anagram
LETTER_MAP = ('a'..'z').zip(Prime.each).to_h
def self.anagram?(word_1, word_2)
word_hash(word_1) == word_hash(word_2)
end
for f in *.png; do mv -n "$f" "$(TZ=UTC+6 date -r "$f" +"%Y%m%d_%H%M").png"; done
montage -label %f *.png -tile 5x1 -geometry +0+0 -pointsize 50 out.png
@peagha
peagha / fix_photo_datetime.rb
Last active January 9, 2017 01:21
Fixes my photos date / time by applying the difference between the registered and the correct date. Requires `mini_exiftool` Gem and "ExifTool by Phil Harvey"
require 'mini_exiftool'
def correct_date_time(wrong_date_time, offset)
c = wrong_date_time + offset
# Removes timezone
Time.new(c.year, c.month, c.day, c.hour, c.min, c.sec)
end
def apply_offset_to_photo(path, offset)
"  some string  ".strip
@peagha
peagha / penny.rb
Created August 23, 2016 00:56
Calls Penny 3 times
def knock_the_door
`afplay /System/Library/Sounds/Pop.aiff`
end
def call_penny
`say "penny" --rate 300`
sleep 0.2
3.times { knock_the_door }
end
use_synth :fm
interval = 0.13
chord1 = [:fs5, :b5, :d6]
chord2 = [:gs5, :b5, :d6]
chord3 = [:b5, :e6, :g6]
chord4 = [:a5, :cs6, :e6]
chord5 = [:fs6, :b5, :d6]
@peagha
peagha / step_through_commits.sh
Created June 27, 2016 23:02
Starts at the beginning of the git history and steps one commit every time 'enter' is hit
for commit in $(git rev-list master --reverse)
do
git checkout $commit
read
done