Skip to content

Instantly share code, notes, and snippets.

View daneb's full-sized avatar
🏠
Working from home

Dane Balia daneb

🏠
Working from home
View GitHub Profile
@daneb
daneb / readme.md
Last active April 30, 2019 05:13
Using SysV init files with SystemD - Ubuntu
  1. Let's say you have a SysV Init Script named myservice
  2. Copy the file to /etc/init.d/myservice
  3. Enable the SysV service: update-rc.d myservice defaults
  4. Start the service: service myservice start.
  5. After this, systemd-sysv-generator will generate this file /run/systemd/generator.late/myservice.service.
    Copy this file to /etc/systemd/system by running: cp /run/systemd/generator.late/myservice.service /etc/systemd/system/myservice.service
  6. Edit /etc/systemd/system/myservice.service by running systemctl edit myservice.service. Add in the following line to myservice.service (this makes the service installable)
@daneb
daneb / problem1.rb
Last active June 26, 2017 21:25
Ruby
def get_sum(input)
input.inject(0) { |total, x| total + x }
end
if __FILE__ == $0
count = 0
total = 0
input = []
$stdin.each_line do |line|
if count.zero?
{"title":"danebalia.com","version":"0.3.2","plugins":{"active":["ory-editor-plugins-slate","ory-editor-plugins-video","ory-editor-plugins-spacer","ory-editor-plugins-image"],"fallback":"ory-editor-plugins-slate"},"baseUrl":"http://www.danebalia.com","design":{"id":"ory-design-vipin","config":{"ory-design-vipin":{"headerTitle":"Dane Balia","themeColor":""}}},"menus":{"main":[{"id":"6c2f62fd-92af-4886-82ad-52890e0ecad4","title":"Home","type":"PAGE","page":"8596e49f-b6dc-4e66-9261-dee6b0bf5df3"}]},"blocks":{"footer":{"id":"4c93bb8d-aa79-49c4-97fa-477237bb4c69","cells":[{"id":"ffc0df79-c469-4cab-8d48-2b5791be1ab4","inline":null,"size":12,"content":{"plugin":{"name":"ory/editor/core/content/slate","version":"0.0.1"},"state":{"serialized":{"nodes":[{"kind":"block","type":"PARAGRAPH/PARAGRAPH","nodes":[{"kind":"text","text":""}]}]}}}}]}},"id":"b0fed921-4936-4062-92ed-5bbe0d8c024a"}
@daneb
daneb / scratchpad.fsx
Created May 8, 2017 19:16
F# Listing 35.1
#load "Domain.fs"
#load "Operations.fs"
#r @"C:\Users\Dane Balia\Documents\Visual Studio 2015\Projects\learnfsharp\src\code-listings\lesson-35\packages\FSharp.Data.SqlClient.1.8.2\lib\net40\FSharp.Data.SqlClient.dll"
open Capstone6.Operations
open Capstone6.Domain
open System
open FSharp.Data
@daneb
daneb / error.rb
Created August 23, 2016 13:47
Error from Adaptor
=> {"whmcs_client_id"=>"8", "domain_name"=>"fai004_truservplus_jhb1_001", "billing_cycle"=>"monthly", "domain_action"=>"register", "reg_period"=>"1", "product_id"=>"25", "additional_fields"=>{:client_number=>"C0656613315", :distro=>"debian"}}
irb(main):008:0> b.create_order(billing_options)
=> {"error_parsing_body"=>"result=error;message=Invalid TLD/Registration Period Supplied for Domain Registration;"}
@daneb
daneb / client.rb
Created July 27, 2016 12:27
Api Auth
@access_id = "1234"
@secret_key = ''
#@secret_key = 'helo'
body = {"hello" => "world"}.to_json
#body = 'dfqwfhadskfhasdkjlfhasdkljfhasdkljfhasklfjash'
headers = { 'Content-MD5' => Digest::MD5.base64digest(body),
'Content-Type' => "application/json",
'Date' => "#{Time.now.httpdate}",
"Authorization" => ''
}
def hello
binding.pry
@access_id = "1234"
#uri = URI.parse('http://127.0.0.1:9292')
uri = URI.parse('http://127.0.0.1:9393/ping')
@request = Net::HTTP::Get.new(uri.request_uri)
@request.add_field("Authorization", headers)
@signed_request = ApiAuthClient.signed_request(@request, @access_id)
@daneb
daneb / extend.rb
Created July 21, 2016 11:11
Jsender Extend vs Include
require 'jsender'
module Hello
extend Jsender
def self.world
self.success('moo')
end
end
@daneb
daneb / environment.yml
Created July 20, 2016 08:29
Configuration Service
CFGSRV_PROVIDER_ADDRESS: 'https://vault.auto-h.net'
CFGSRV_IDENTIFIER: 'shield'
CFGSRV_TOKEN: '<revision-from-configuration-service-ui>'
CFGSRV_PROVIDER: 'vault'
IDENTIFIER: 'shield'
SESSION_KEY: 'session_key_shared_amongst_application_instances'
SESSION_SECRET: 'strong_secret_shared_amongst_application_instances'
RACK_ENV: 'development'
SERVICE_REGISTRY: 'http://service-registry.auto-h.net:8080'
@daneb
daneb / config.ru
Last active July 17, 2016 13:20
Rack::Cors Configuration Middleware
require 'rack'
require './cors_wired'
app = Rack::Builder.new do
use CorsWired.new
run lambda { |env| [200, {'Content-Type' => 'text/plain'}, ['OK']] }
end
run app