Skip to content

Instantly share code, notes, and snippets.

$ irb
irb(main):001:0> require 'yaml'
=> true
irb(main):002:0> YAML::load_file 'test.yaml'
=> {"foo"=>"bar"}
irb(main):003:0> ^D
$ python
Python 3.6.5 (default, Apr 25 2018, 14:23:58)
[GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
// cryptopals 1.6
package main
import (
"os"
"fmt"
"encoding/base64"
"math"
"strings"
"io/ioutil"
package main
import (
"fmt"
"encoding/hex"
"strings"
)
func main () {
def getjson
thejson = ''
uri = URI.parse("http://#{@dump1090host}:#{@dump1090port}/data.json")
begin
Timeout::timeout(1) {
thejson = Net::HTTP.get(uri) rescue {}
}
rescue Timeout::Error => e
log 'Getting the JSON timed out'
log e.message
Nov 4 11:21:52 raspberrypi noisemon: {"hex"=>"70604e", "flight"=>"KAC104 ", "lat"=>51.453956, "lon"=>-0.534058, "altitude"=>2400, "track"=>227, "speed"=>167, :distance=>2.5128381354906066}
Nov 4 11:21:53 raspberrypi noisemon: {"hex"=>"70604e", "flight"=>"KAC104 ", "lat"=>51.452326, "lon"=>-0.536804, "altitude"=>2425, "track"=>227, "speed"=>167, :distance=>2.5436887611907655}
Nov 4 11:21:54 raspberrypi noisemon: {"hex"=>"70604e", "flight"=>"KAC104 ", "lat"=>51.451721, "lon"=>-0.537796, "altitude"=>2425, "track"=>227, "speed"=>170, :distance=>2.5582822086619865}
Nov 4 11:21:55 raspberrypi noisemon: {"hex"=>"70604e", "flight"=>"KAC104 ", "lat"=>51.45108, "lon"=>-0.53885, "altitude"=>2450, "track"=>226, "speed"=>173, :distance=>2.575109039354822}
Nov 4 11:21:56 raspberrypi noisemon: {"hex"=>"70604e", "flight"=>"KAC104 ", "lat"=>51.450211, "lon"=>-0.540112, "altitude"=>2475, "track"=>226, "speed"=>175, :distance=>2.603431262425656}
Nov 4 11:21:57 raspberrypi noisemon: {"hex"=>"70604e", "flight"=>"KAC104
@fiddyspence
fiddyspence / gist:7585436
Created November 21, 2013 16:56
Broken/missing init script
service { 'iptables':
ensure => stopped,
enable => false,
hasstatus => false,
status => 'if [ -f /etc/init.d/iptables ]; then service iptables status; else false; fi',
}
#!/opt/puppet/bin/puppet apply
include foo
class foo {
notify {'foomomomo': }
}
class mcocertcollector ( $mcoclass = 'pe_mcollective', $clientpubkeydir = '/tmp/foo' ) {
$hosts = query_nodes("Class[${mcoclass}]")
file { $clientpubkeydir:
ensure => directory,
purge => true,
recurse => true,
}
https://github.com/jordansissel/fpm
require 'irb/completion'
# THIS FILE MANAGED BY PUPPET - EDIT BY HAND AT YOUR PERIL
<% foo = scope.to_hash -%>
<% foo.sort.each do |k,v| -%>
<%= "#{k} = #{v}" %>
<% end -%>
#!/bin/env ruby
require 'yaml'
require "net/https"
require 'socket'
node=ARGV[0]
http = Net::HTTP.new('localhost', 443)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
begin