Skip to content

Instantly share code, notes, and snippets.

View ZakharDay's full-sized avatar

ZakharDay ZakharDay

View GitHub Profile
@davidteren
davidteren / Rails, Puma & Nginx.md
Last active July 8, 2024 16:15
Example setup for Puma with Nginx in a Rails app

In the apps config/puma.rb file:

Change to match your CPU core count
# Check using this on the server => grep -c processor /proc/cpuinfo
workers 4

# Min and Max threads per worker
threads 1, 6

app_dir = File.expand_path('../..', FILE)

@yokotaso
yokotaso / webpack.config.js
Last active August 26, 2022 05:26
webpack.config.js with babel, polyfill
const path = require('path');
module.exports = {
mode: "development",
entry: {
'polyfill': '@babel/polyfill',
'kintone-create-edit-show': './src/kintone-create-edit-show.js'
},
module: {
rules: [
@sibsfinx
sibsfinx / prepare_hd.sh
Last active February 12, 2018 00:54
Prepare external drive on mac fucking OS
# list disks:
diskutil list
# use disk name from the listed isntead of disk3
# unmount your external drive:
diskutil unmountDisk force disk3
# format in HFS with the name you want:
diskutil partitionDisk disk3 GPT JHFS+ "Drive Name" 0g
@schweigert
schweigert / Embedding GoLang into a Ruby application.md
Last active July 17, 2024 13:50
Embedding GoLang into a Ruby application - Blogpost to Magrathealabs

Go Title

I am passionate about Ruby, but its execution time compared to other languages is extremely high, especially when we want to use more complex algorithms. In general, data structures in interpreted languages become incredibly slow compared to compiled languages. Some algorithms such as ´n-body´ and ´fannkuch-redux´ can be up to 30 times slower in Ruby than Go. This is one of the reasons I was interested in embedding Go code in a Ruby environment.

For those who do not know how shared libraries operate, they work in a similar way as DLLs in Windows. However, they have a native code with a direct interface to the C compiler.

Note Windows uses the DLL system, and in this case, this does not necessarily have to be in native code.

One example is DLLs written in C#, which runs on a virtual machine. Because I do not use windows, I ended up not testing if it is poss

@ryanbaumann
ryanbaumann / index.html
Last active February 3, 2023 08:05
Example of loading large geojson into Mapbox GL JS
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<title></title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v2.6.0/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v2.6.0/mapbox-gl.css' rel='stylesheet' />
<link href='https://www.mapbox.com/base/latest/base.css' rel='stylesheet' />
@ZhihaoLau
ZhihaoLau / times.js
Created October 14, 2016 02:42
‘Ruby times method’ in JavaScript
// Ruby = 5.times { |i| puts i }
// JS = (1).times(function(i){console.log(i);})
Number.prototype.times = function(cb) {
var i = -1;
while (++i < this) {
cb(i);
}
return +this;
@fernandoaleman
fernandoaleman / fix-libv8-mac.txt
Created May 5, 2016 15:14
Fixing libv8 and therubyracer on Mac
brew tap homebrew/versions
brew install v8-315
gem install libv8 -v '3.16.14.13' -- --with-system-v8
gem install therubyracer -- --with-v8-dir=/usr/local/opt/v8-315
bundle install
@thejbsmith
thejbsmith / Rails Singleton Model
Last active April 16, 2024 00:29
Rails Singleton Model
Rails Singleton Model
Taken from:
http://stackoverflow.com/questions/399447/how-to-implement-a-singleton-model/12463209#12463209
@MathewReiss
MathewReiss / phone.js
Created June 4, 2015 17:09
Pokedex phone.js File
var DEBUG = true;
//var name = "name", type = "type", stage = "stage", caught = "caught";
var grass = "grass", water = "water", fire = "fire", bug = "bug",
psychic = "psychic", flying = "flying", ghost = "ghost", fighting = "fighting",
normal = "normal", poison = "poison", electric = "electric", ground = "ground",
fairy = "fairy", rock = "rock", ice = "ice", dragon = "dragon";
var Pokemon = [
{ name : "MissingNo", type : "blank", stage : 100, caught : 0, species : "Glitch Pokemon"},
@GaspardP
GaspardP / sha256.js
Created June 4, 2015 15:21
SHA-256 with Javascript and Web Crypto
// Computes the SHA-256 digest of a string with Web Crypto
// Source: https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest
function sha256(str) {
// Get the string as arraybuffer.
var buffer = new TextEncoder("utf-8").encode(str)
return crypto.subtle.digest("SHA-256", buffer).then(function(hash) {
return hex(hash)
})
}