Skip to content

Instantly share code, notes, and snippets.

Avatar
🤓
IoT'ing

Thomas Peter Berntsen tpberntsen

🤓
IoT'ing
View GitHub Profile
@wassname
wassname / jupyter_logging.py
Last active Sep 21, 2020
simple logging for jupyter or python which outputs to stdout (or a console or terminal) and a log file
View jupyter_logging.py
"""
In jupyter notebook simple logging to console
"""
import logging
import sys
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
# Test
logger = logging.getLogger('LOGGER_NAME')
@jeffjohnson9046
jeffjohnson9046 / ruby-ldap-sample.rb
Last active Aug 17, 2020
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 Apr 6, 2020
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;
@rtomayko
rtomayko / optparse-template.rb
Last active Jan 19, 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"
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
@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
You can’t perform that action at this time.