Skip to content

Instantly share code, notes, and snippets.

View vforge's full-sized avatar
🔜
Great things!

Bartosz V. Bentkowski vforge

🔜
Great things!
View GitHub Profile
@vforge
vforge / mersenne-twister.ts
Last active September 7, 2022 04:08 — forked from banksean/mersenne-twister.js
A Mersenne Twister implementation in TypeScript. Makes up for Math.random() not letting you specify a seed value.
/*
* TypeScript port by Bartosz V. Bentkowski
*
* gist: https://gist.github.com/vforge/0aa8555507a0b06849cd20b142c3f74d
*/
/*
I've wrapped Makoto Matsumoto and Takuji Nishimura's code in a namespace
so it's better encapsulated. Now you can have multiple random number generators
and they won't stomp all over eachother's state.
[profile]
layer_height = 0.15
wall_thickness = 1.2
retraction_enable = True
solid_layer_thickness = 1.2
fill_density = 15
print_speed = 50
print_temperature = 200
print_temperature2 = 0
print_temperature3 = 0
@vforge
vforge / RPi_I2C_driver.py
Created February 28, 2019 07:17 — forked from DenisFromHR/RPi_I2C_driver.py
RaspberryPi I2C LCD Python stuff
# -*- coding: utf-8 -*-
"""
Compiled, mashed and generally mutilated 2014-2015 by Denis Pleic
Made available under GNU GENERAL PUBLIC LICENSE
# Modified Python I2C library for Raspberry Pi
# as found on http://www.recantha.co.uk/blog/?p=4849
# Joined existing 'i2c_lib.py' and 'lcddriver.py' into a single library
# added bits and pieces from various sources
# By DenisFromHR (Denis Pleic)
@vforge
vforge / gist:179716f77750bc3c349b
Last active August 29, 2015 14:27 — forked from mediasota/gist:7c46c8e105acc386d62f
config/initializers/simple_form_materialize-sass.rb
# Use this setup block to configure all options available in SimpleForm.
SimpleForm.setup do |config|
config.error_notification_class = 'alert alert-danger'
config.button_class = 'waves-effect waves-light btn'
config.boolean_label_class = nil
config.wrappers :vertical_form, tag: 'div', class: 'input-field', error_class: 'has-error' do |b|
b.use :html5
b.use :placeholder
b.optional :maxlength
@vforge
vforge / index.md
Last active August 29, 2015 14:22 — forked from rstacruz/index.md

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one

CSS linear-gradient overlay

⚠ Only works properly in Firefox for now - the tool will be displayed in other browsers, but if you change the color formats from rgb[a] to something else, the overlay won't update ⚠

This tool overlays information on top of a CSS linear-gradient to help understand how it is rendered in browsers.

If you read the spec (http://dev.w3.org/csswg/css-images/#linear-gradients) carefully, you'll learn a tone of details about how linear gradients are constructed you might not know. This tool's goal is to make it more obvious how the gradient angle is calculated and how the color stops are positioned.

Tool usage:

SSL upgrades on rubygems.org and RubyInstaller versions

UPDATE 2014-12-21: RubyGems 1.8.30, 2.0.15 and 2.2.3 have been released. It requires manual installation, please see instructions below.


Hello,

If you reached this page, means you've hit this SSL error when trying to

@vforge
vforge / README.md
Last active August 29, 2015 14:15 — forked from fnichol/README.md

Why?

There is a long standing issue in Ruby where the net/http library by default does not check the validity of an SSL certificate during a TLS handshake. Rather than deal with the underlying problem (a missing certificate authority, a self-signed certificate, etc.) one tends to see bad hacks everywhere. This can lead to problems down the road.

From what I can see the OpenSSL library that Rails Installer delivers has no certificate authorities defined. So, let's go fetch some from the curl website. And since this is for ruby, why don't we download and install the file with a ruby script?

Installation

The Ruby Way! (Fun)

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert $1 -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 $2

Results

!!! 5
-# paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/
/[if lt IE 7] <html class="no-js ie6 oldie" lang="en">
/[if IE 7] <html class="no-js ie7 oldie" lang="en">
/[if IE 8] <html class="no-js ie8 oldie" lang="en">
-# Consider adding a manifest.appcache: h5bp.com/d/Offline
/[if gt IE 8] <!--> <html class="no-js" lang="en"> <!--
%head
%meta{:charset => 'utf-8'}