Skip to content

Instantly share code, notes, and snippets.

@TvL2386
TvL2386 / gist:5501113
Created May 2, 2013 09:13
Testing icontrol-0.3.9 VirtualServer creation and destroy. The F5 has firmware version: BIG-IP 11.3.0 Build 2968.0 Hotfix HF1
require 'icontrol'
require 'awesome_print'
require 'yaml'
IControl.config = { user: 'admin', password: 'secret', base_url: 'https://192.168.0.60' }
ap IControl::LocalLB::VirtualServer.find(:all)
puts
manifest = {
:definition => {
@TvL2386
TvL2386 / app_models_foo_bar_bar.rb
Last active December 20, 2015 09:59
In rails 3.2 development, running Foo::Bar.say_hi in the console gives: NoMethodError: undefined method `say_hi' for Foo::Bar:Module
module Foo
module Bar
def self.say_hi
puts "hi"
end
end
end
@TvL2386
TvL2386 / gist:6447834
Created September 5, 2013 09:15
Net::SCP keeps failing...
require 'net/scp'
# using:
#* net-scp (1.1.2)
#* net-ssh (2.6.8)
# Both fail
Net::SCP.download!('localhost', 'me','/tmp/bla.rb','/tmp/bla2.rb', password: 'mypass')
Net::SCP.download!('localhost', 'me','/tmp/bla.rb','/tmp/bla2.rb', password: 'mypass', ssh: {auth_methods: %w(password)})
@TvL2386
TvL2386 / gist:8577594
Created January 23, 2014 12:11
example json put request with optional SSL
require 'net/https'
require 'json'
host = 'localhost'
port = 3000
path = '/controller/upload.json?key=bla'
json = {}.to_json
http = Net::HTTP.new host, port
#http.use_ssl = true
@TvL2386
TvL2386 / gist:11338885
Created April 27, 2014 06:26
My First C Sharp Unit Testing
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using MyNamespace;
namespace MyNamespaceTests
{
[TestClass]
public class EncryptionTests
{
[TestMethod]
@TvL2386
TvL2386 / gist:00f432b0c322de62d2ca
Created May 6, 2014 14:40
User is not working as expected
# SNIPPET FROM MY MODULE #
user { 'myuser':
require => Package["bla"],
name => 'myuser',
password => '$6$OszcHZZq$/PLagjQvt3jG/zfM1S/vU5vF4dMEXzdrPcc2.Iih01TxhN8004sQIKJpXQd5K7JySWIHSGwTHnY0mKrqFQd3H1',
ensure => present,
home => '/opt/myuser',
comment => 'myuser agent user (managed by puppet)',
managehome => true,
shell => '/bin/bash',
@TvL2386
TvL2386 / gist:1230a2be23d2b9d8352f
Created October 2, 2014 12:57
Convert bind zone file to powerdns gmysql
root@pollux:/etc/powerdns/bind# cat 0.168.192.ip-addr.arpa.zone
$ORIGIN 0.168.192.in-addr.arpa. ; start of this zone file in the name space, not necessary if included from named.conf
$TTL 1d ; default expiration time of all resource records without their own TTL value
@ IN SOA ns.example.com postmaster.example.com. ( ; @ is replaced with . in email address
2014022602 ; serial number of this zone file
1d ; slave refresh (1 day)
2h ; slave retry time in case of a problem (2 hours)
4w ; slave expiration time (4 weeks)
1h ; minimum caching time in case of failed lookups (1 hour)
#!/bin/bash
inputfiles=(*.mp4)
declare -a outputfiles
for file in "${inputfiles[@]}"
do
outputfiles+=("${file%.*}.test.${file##*.}")
done
@TvL2386
TvL2386 / scheduler.php
Last active January 8, 2018 04:53
my scheduler
$ php artisan schedule:daemon
[2018-01-07 12:11:24] Starting schedule:daemon
[2018-01-07 12:11:24] Waiting for next minute
[2018-01-07 12:12:00] running main loop
Running scheduled command: App\Jobs\CreateSnapshot
[2018-01-07 12:13:00] running main loop
Running scheduled command: App\Jobs\CreateSnapshot
[2018-01-07 12:14:00] running main loop
Running scheduled command: App\Jobs\CreateSnapshot
[2018-01-07 12:15:00] running main loop
0417331a1caa3b74022ad00a8b6478343b8fa137eff39281271a399c0ad9b88c9e75dd59ab08c7b15835d721feb3411cada47038b2fa5e293a697c6068532ea7d7