Skip to content

Instantly share code, notes, and snippets.

View jnsprnw's full-sized avatar
🍊
Making smoothies

Jonas jnsprnw

🍊
Making smoothies
View GitHub Profile
@jnsprnw
jnsprnw / GeoDistance.rb
Created February 20, 2017 18:08
Calculate distance between two coordinates
#!/usr/bin/env ruby
class GeoDistance
R = 6371000
def toRadians (v)
return v * Math::PI / 180.0;
end
def calc (a, b)
@jnsprnw
jnsprnw / readWriteCSV.rb
Created February 22, 2017 10:17
snippets for reading and writing csv files in ruby
def readCSV (file)
CSV.read(file, { encoding: "UTF-8", headers: true, header_converters: :symbol, converters: :all }).map { |d| d.to_hash }
end
def writeCSV (file, hash)
CSV.open(file, "w") do |row|
row << hash.first.keys
hash.each { |obj| row << obj.values }
end
end
@jnsprnw
jnsprnw / reformat.rb
Last active February 23, 2017 10:04
reformat csv files – delete unwanted columns, squeeze and strip columns, fill placeholders
#!/usr/bin/env ruby
require 'csv'
require 'awesome_print'
require 'json'
class Hash
def checkKeys!(allowed_keys)
self.keys.each { |key| delete(key) unless allowed_keys.include? key }
self
end
{
"1": {
"name": "Fareedoone Aryan",
"id": 1,
"reports": [
"21"
],
"location": "Kabul",
"latitude": 34.555649,
"longitude": 69.205927,
@jnsprnw
jnsprnw / .htaccess
Created March 20, 2017 09:17
HTACCESS to redirect all requests to root for React Router to handle them
<IfModule mod_rewrite.c>
RewriteEngine On
# redirect all to index
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ / [L,NC]
</IfModule>

Unicode/HTML characters

Striche

Sign Description Unicode Mac
Bindestrich U+2010
Gedankenstrich (Halbgeviertstrich) U+2013 ⌥ + -
Subtraktionszeichen (Minus) U+2212
Spiegelstrich (Geviertstrich) U+2014 ⇧ + ⌥ + -
Geschützer Bindestrich &#8209; \2011

Music for working, programming, reading, …

…sleeping, meditating, yoga, after hour…. Mostly ambient, drone, (neo-)classical, dub, minimal techno, deep house, micro house, downtempo, slo-mo house, ketapop, schneckno, jetlagdisco, post-rock, lowfi hip hop…

Please feel free to comment your recommendations.

#!/usr/bin/env ruby
# encoding: utf-8
Dir.chdir(File.dirname(__FILE__))
require "awesome_print"
# Skript um ein Spaltenlayout für zwei unterschiedliche Breiten zu finden
BREITE_1 = 250
BREITE_2 = 200
<template>
  <div ref="result">
    {{ result }}
  </div>
</template>

<script>

export default {