Skip to content

Instantly share code, notes, and snippets.

View hsjunnesson's full-sized avatar

Hans Sjunnesson hsjunnesson

View GitHub Profile
@hsjunnesson
hsjunnesson / poisson.rb
Created January 25, 2024 21:03
poisson.rb
require 'victor'
require 'perlin_noise'
$width = 279
$height = 356
$pen_width = 0.8
$margin_left = 10
$margin_right = 10
@hsjunnesson
hsjunnesson / vellum.rb
Created January 23, 2024 21:25
A Ruby script that outputs some Perlin perturbed SVGs
require 'victor'
require 'perlin_noise'
$width = 210
$height = 297
# $width = 279
# $height = 356
$pen_width = 0.8
@hsjunnesson
hsjunnesson / Seraphon Warscrolls.html
Last active March 31, 2020 10:48
A web tool to show Seraphon Warscrolls. Just download to your computer and open in a browser.
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
@hsjunnesson
hsjunnesson / main.c
Created October 1, 2019 19:06
Embedded Racket in C
#include "scheme.h"
#include "base.c"
static int run(Scheme_Env* e, int argc, char* argv[]) {
scheme_env = e;
declare_modules(e);
scheme_namespace_require(scheme_intern_symbol("racket/base"));
@hsjunnesson
hsjunnesson / TicTacToe.sol
Created January 10, 2018 15:44
Tic Tac Toe on Ethereum
pragma solidity ^0.4.0;
/**
* @title Ownable
* @dev The Ownable contract has an owner address, and provides basic authorization control
* functions, this simplifies the implementation of "user permissions".
*/
contract Ownable {
address public owner;
@hsjunnesson
hsjunnesson / gist:9e07291b7ccd35cea269
Created September 16, 2014 17:03
CirclePhotoView.playground
// Playground - noun: a place where people can play
import UIKit
import QuartzCore
@IBDesignable
public class CirclePhotoView: UIView {
@IBInspectable public var image: UIImage?

Marble diagrams

A notation for diagramming signals.

A line signifies time.

──────────────────────────>
@hsjunnesson
hsjunnesson / scrollviewcontroller.m
Last active August 29, 2015 14:01
Using ReactiveCocoa to get rid of the scroll view delegate, to update a UIPageControl's currentPage as you scroll.
CGFloat pageWidth = CGRectGetWidth(self.scrollView.frame);
RAC(self.pageControl, currentPage) = [RACObserve(self.scrollView, contentOffset) map:^id(NSValue *value) {
CGPoint contentOffset = [value CGPointValue];
NSUInteger page = floor((contentOffset.x - pageWidth / 2) / pageWidth) + 1;
return @(page);
}];
@hsjunnesson
hsjunnesson / gist:7450562
Created November 13, 2013 15:07
How to programmatically scroll a tableview to the top, then run a block when it's done animating. #ReactiveCocoa
[[[RACObserve(self.tableView, contentOffset)
filter:^BOOL(NSValue *contentOffset) {
CGPoint point = [contentOffset CGPointValue];
return point.y == 0.0f;
}]
take:1]
subscribeCompleted:^{
// This block gets executed when the tableview has scrolled to top
}];
#import <Foundation/Foundation.h>
typedef void(^SuccessBlock)(id object);
typedef void(^ErrorBlock)(NSString *error);
@interface JenkinsRequest : NSObject
@property (copy) SuccessBlock successBlock;
@property (copy) ErrorBlock errorBlock;