Skip to content

Instantly share code, notes, and snippets.

Avatar

Alexander Presber momolog

View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am momolog on github.
  • I am saimiri (https://keybase.io/saimiri) on keybase.
  • I have a public key ASC-Jrd7IYVblYeHOQZZM4f_lvM7wK1e9Wp-UbiwXg2KrAo

To claim this, I am signing this object:

View gist:fa6ed94b77e98e38eea474699a71683a
#!/usr/bin/env ruby
require 'json'
require 'httparty'
headers = {
'PRIVATE-TOKEN' => ENV['GITHOST_PERSONAL_API_TOKEN']
}
(1..121).each do |pid|
@momolog
momolog / githost-move-vars
Last active May 29, 2019
githost to gitlab variable transfer
View githost-move-vars
#!/usr/bin/env ruby
# move me to ~/bin/githost-move-vars, make me executable and
# call me like githost-move-vars 101 1258608
require "httparty"
# WARNINGS:
# only works for up to 100 variables
# doesn't copy protected nor masked checkboxes
@momolog
momolog / nap
Created Jan 30, 2019
nap utility, put this into `~/bin/nap`
View nap
#!/bin/bash
if [ -z $1 ]; then
echo "No time provided. Usage: nap [-cl] [minutes]"
exit 2
fi
if [[ $1 == *c ]]; then
echo Cancelling sleep. PIDs \(if any\): `pgrep -f "nap"`
pkill -f "nap"
exit 0
fi
@momolog
momolog / test.rb
Created Mar 9, 2018
Runs just fine with "ruby test.rb" under ruby 2.5
View test.rb
require 'factory_bot'
class Training
attr_accessor :instructor
def save!; end
end
class User
attr_accessor :role
def save!; end
@momolog
momolog / Gemfile
Created Feb 25, 2018 — forked from roalcantara/Gemfile
Rails 4 + Paperclip + Amazon S3
View Gemfile
#https://github.com/thoughtbot/paperclip
#http://rubydoc.info/gems/paperclip/Paperclip/Storage/S3
gem 'paperclip', github: 'thoughtbot/paperclip'
# S3 API
gem 'aws-sdk'
View PHP emptiness
Test $a $b
isset() false false
empty() true true
is_null() true true
=== null true true
View Ruby Struct Initialization
2.2.2 :010 > s = Struct.new(:member)
=> #<Class:0x007fc96203f2e0>
2.2.2 :011 > my_struct = s['value']
=> #<struct member="value">
View offcanvas.sass
$navi-width: 200px
html
height: 100%
margin: 0
body
margin: 0
height: 100%
.site-wrapper
position: relative
View searchbox.jsx.coffee
{div, h1, h2, img, form, input} = React.DOM
@SearchBox = React.createClass
render: ->
div className: 'searchbox-container',
React.createElement Form, searchText: this.state.searchText, onSearchChange: this.searchChanged, onFocus: this.onFocus, onBlur: this.onBlur
React.createElement ResultList, data: this.state.data, category: this.state.category, visible: (this.state.hasResults && this.state.focus)
searchChanged: (val) ->
clearTimeout(this.searchTimeout)