This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class OpenSSHKey | |
def self.valid? key | |
string=key.to_s | |
oneliner = string.lines.count>1 ? to_openssh(string) : string | |
tmpfile="/tmp/openssh-check-#{rand(1000000).to_i}" | |
File.open(tmpfile, "w") { |file| file.puts oneliner} | |
begin | |
system "ssh-keygen -l -f '#{tmpfile}' >/dev/null 2>/dev/null" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def json_or_jsonp( json ) | |
callback = params.delete('callback') | |
if callback | |
content_type :js | |
response = "#{callback}(#{json})" | |
else | |
content_type :json | |
response = json | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/sh | |
# PulseAudio setup for recording osm radio from skype and mic | |
function rec_start() { | |
IP=127.0.0.1 | |
PASSWORD=password | |
DATE=$(date +%y%m%d-%H%M) | |
# Initializing microphone | |
MIC_ID=$(pactl list short sources|grep GoMic|grep input|cut -f 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "log" | |
type A interface { | |
SetId(string) | |
} | |
type B struct{ | |
Afield A |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Mytype must implement Less func. | |
func SortedInsert (s []Mytype, f Mytype) []Mytype { | |
l:=len(s) | |
if l==0 { return [f] } | |
i := sort.Search(l, func(i int) bool { return s[i].Less(f)}) | |
if i==l { // not found = new value is the smallest | |
return append([f],s) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
#include <stdlib.h> | |
#include <dirent.h> | |
#include <math.h> | |
#include <fcntl.h> | |
#include <assert.h> | |
#include <malloc.h> | |
#include <sys/mman.h> | |
#include <sys/types.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Check if an IP address is listed on one of the following blacklists | |
# The format is chosen to make it easy to add or delete | |
# The shell will strip multiple whitespace | |
BLISTS=" | |
bl.score.senderscore.com | |
bl.mailspike.net | |
bl.spameatingmonkey.net | |
b.barracudacentral.org |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'dry-validation' | |
schema = Dry::Validation.Schema do | |
required(:field_1).filled(:str?) | |
required(:field_2).filled(:int?) | |
rule(field_2_depends_on_field_1: [:field_1, :field_2]) do |field_1, field_2| | |
field_1.eql?('Foo').then(field_2.eql?(0)) & field_1.eql?('Bar').then(field_2.eql?(1)) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source 'https://rubygems.org' | |
gem 'rom' | |
gem 'rom-sql' | |
gem 'rom-yaml', '2.0.0.rc2' | |
gem 'sqlite3' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# TURN OFF HDMI if not in use | |
# Get the current video output type and strip away the unimportant bits | |
video="$(tvservice -s | sed "s/^.*\[\([^ ]*\) .*$/\1/" )" | |
if [ "$video" != "HDMI" ]; then | |
printf "HDMI not detected. Turning off.\n" | |
tvservice -off > /dev/null | |
else | |
printf "HDMI detected.\n" | |
fi |
OlderNewer