Skip to content

Instantly share code, notes, and snippets.

🤓
IoT'ing

Thomas Peter Berntsen tpberntsen

🤓
IoT'ing
Block or report user

Report or block tpberntsen

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View darkify_slack.sh
#!/bin/sh
# Darkify Slack on Mac OS or Linux.
# curl https://gist.githubusercontent.com/ryanpcmcquen/8a7ddc72460eca0dc1f2dc389674dde1/raw/darkify_slack.sh | sh
if [ "`uname -s`" = "Darwin" ]; then
SLACK_INTEROP_JS="/Applications/Slack.app/Contents/Resources/app.asar.unpacked/dist/ssb-interop.bundle.js"
else
SLACK_INTEROP_JS="/usr/lib/slack/resources/app.asar.unpacked/dist/ssb-interop.bundle.js"
fi
@jeffjohnson9046
jeffjohnson9046 / ruby-ldap-sample.rb
Last active Nov 14, 2019
Some VERY basic LDAP interaction in Ruby using Net::LDAP.
View ruby-ldap-sample.rb
#######################################################################################################################
# This Gist is some crib notes/tests/practice/whatever for talking to Active Directory via LDAP. The (surprisingly
# helpful) documentation for Net::LDAP can be found here: http://net-ldap.rubyforge.org/Net/LDAP.html
#######################################################################################################################
require 'rubygems'
require 'net/ldap'
#######################################################################################################################
# HELPER/UTILITY METHOD
@elyezer
elyezer / ring_buffer.sql
Last active May 6, 2019
How to create a ring buffer table in SQLite
View ring_buffer.sql
-- Example table
CREATE TABLE ring_buffer (id INTEGER PRIMARY KEY AUTOINCREMENT, data TEXT);
-- Number 10 on where statement defines the ring buffer's size
CREATE TRIGGER delete_tail AFTER INSERT ON ring_buffer
BEGIN
DELETE FROM ring_buffer WHERE id%10=NEW.id%10 AND id!=NEW.id;
END;
@indirect
indirect / child.rb
Created Jun 14, 2013
ruby child process with non-buffered output
View child.rb
# give the child process a terminal so output isn't buffered
@master, slave = PTY.open
in_clean_environment do
@pid = ::Process.spawn(
config.env,
%Q(bash -c "#{config.command}"),
:in => slave,
:out => slave,
:err => slave,
:chdir => config.dir,
@abhishek77in
abhishek77in / report.rb
Created Dec 9, 2012
Create a PDF Document using Prawn Library with header, footer and page numbering.
View report.rb
require "prawn"
Prawn::Document.generate("report.pdf") do
10.times do
start_new_page
end
repeat :all do
move_down 50
@rtomayko
rtomayko / optparse-template.rb
Last active Jan 11, 2020
Ruby optparse template
View optparse-template.rb
#!/usr/bin/env ruby
#/ Usage: <progname> [options]...
#/ How does this script make my life easier?
# ** Tip: use #/ lines to define the --help usage message.
$stderr.sync = true
require 'optparse'
# default options
flag = false
option = "default value"
You can’t perform that action at this time.