Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View rbq's full-sized avatar

rbq

  • Germany, NRW
View GitHub Profile
@rbq
rbq / tensorflow_test_script
Last active October 15, 2019 11:02 — forked from donigian/tensorflow_test_script
TensorFlow Test Script
import tensorflow as tf
with tf.device('/cpu:0'):
a_c = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[2, 3], name='a-cpu')
b_c = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[3, 2], name='b-cpu')
c_c = tf.matmul(a_c, b_c, name='c-cpu')
with tf.device('/gpu:0'):
a_g = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[2, 3], name='a-gpu')
b_g = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[3, 2], name='b-gpu')
@rbq
rbq / convert_sqlite_booleans.rb
Created April 30, 2019 09:52
Rails 6 migrations to upgrade SQLite booleans from t/f to 1/0
class ConvertSqliteBooleans < ActiveRecord::Migration[6.0]
BOOLEANS = [
[ 'table_name', 'column_name' ],
[ 'table_name', 'column_name' ],
]
def up
BOOLEANS.each do |table, column|
execute "UPDATE #{table} SET #{column} = 1 WHERE #{column} = 't';"
execute "UPDATE #{table} SET #{column} = 0 WHERE #{column} = 'f' OR #{column} IS NULL;"
@rbq
rbq / docker.yaml
Last active October 19, 2023 11:57
Install Docker CE on Ubuntu using Ansible
---
- hosts: all
tasks:
- name: Install prerequisites for Docker repository
apt:
name: ['apt-transport-https', 'ca-certificates', 'curl', 'gnupg2', 'software-properties-common']
update_cache: yes
- name: Add Docker GPG key
apt_key:
@rbq
rbq / create_labels.sh
Created March 9, 2017 16:45 — forked from omegahm/create_labels.sh
Create Gtihub labels from Bash
#!/usr/bin/env bash
# Colours picked from https://robinpowered.com/blog/best-practice-system-for-organizing-and-tagging-github-issues/
###
# Label definitions
###
declare -A LABELS
# Platform
@rbq
rbq / Gemfile
Last active April 27, 2020 13:48
Convert notes from Snippets.me to Quiver
source 'https://rubygems.org'
gem 'data_mapper'
gem 'dm-sqlite-adapter'
class RDoc::Markup::Formatter
def parse_url url
case url
when /^rdoc-label:([^:]*)(?::(.*))?/ then
scheme = 'link'
path = "##{$1}"
id = " id=\"#{$2}\"" if $2
when /([A-Za-z]+):(.*)/ then
scheme = $1.downcase
path = $2
@rbq
rbq / Animal.txt
Created November 4, 2013 20:02
Animal
#!/usr/bin/env ruby
# coding: utf-8
require 'sinatra'
get '/:animal' do
@all_animals = ['Cat', 'Dog']
@animal = params[:animal] if @all_animals.include? params[:animal]
erb :index
end
@rbq
rbq / config.ru
Created April 22, 2013 21:25
Problem: not_found doesn't work at all
# coding: utf-8
require 'rack/urlmap'
require File.join(File.dirname(__FILE__), 'app')
require File.join(File.dirname(__FILE__), 'api', 'v1')
routes = Rack::URLMap.new(
'/' => Sinatra::Application,
'/api/v1/' => ApiV1
)
@rbq
rbq / uberspace-gem-nokogiri
Created September 22, 2011 17:14
Install the Nokogiri rubygem on Uberspace
# Instructions: http://nokogiri.org/tutorials/installing_nokogiri.html
# See also: https://github.com/tenderlove/nokogiri/issues/243
toast arm libxml libxslt && \
gem install nokogiri -- \
--with-xml2-lib=$HOME/.toast/armed/lib \
--with-xml2-include=$HOME/.toast/armed/include/libxml2 \
--with-xslt-dir=$HOME/.toast/armed
bundle config build.nokogiri \
@rbq
rbq / app.rb
Created September 6, 2011 10:57
Sinatra route for SASS files
get '/:name.css' do
content_type 'text/css', :charset => 'utf-8'
response.headers['Cache-Control'] = 'public, max-age=3600'
sass :"stylesheets/#{params[:name]}"
end