Skip to content

Instantly share code, notes, and snippets.

View henrikj242's full-sized avatar

Henrik 242 Jensen henrikj242

View GitHub Profile
@henrikj242
henrikj242 / GoogleCloudStorageFileExhange.cs
Last active January 29, 2024 20:43
Use the Google Cloud API to upload and download files to/from a bucket using explicit authentication in a C# app.
using Google.Apis.Auth.OAuth2; // Google.Apis.Auth --version 1.30.0
using Google.Cloud.Storage.V1; // Google.Cloud.Storage.V1
using System;
using System.IO;
using System.Runtime.InteropServices;
using static System.Console;
public static class Program
{
public static void Main(string[] args)
using System;
using System.IO;
using System.Net;
using static System.Console;
public static class Program
{
static void Main()
{
WebClient client = new WebClient ();
@henrikj242
henrikj242 / copy_rename.rb
Last active August 3, 2018 20:10
Bash examples
#!/usr/bin/ruby
# We use this script to rename samples. The samples come from Logic, and have then been batch-processed (but not renamed)
# This script renames samples in a specified directory like so:
# - Give them all a three digit numeric suffix.
# - If it's a BD or SD +OSC2 sample, assume it's "colored" and name it accordingly.
# - In all other cases, assume not "colored", and just name it with A (round-robin, not accent) or B (round-robin, accent).
#
# Note that while the dry run does not make any changes, it may not reveal potential issues when running the script for real.
{
This code is for the Native Instruments Kontakt sampler v4 or above.
It may assist in converting between the ksp-specific range (0 - 1_000_000) and decibel (as used to set the volume for groups).
I've also published a list of some values between 100_000 and 1_000_000 in steps of 10_000:
https://docs.google.com/spreadsheets/d/1JmXV9E0mrHkd7ZTm2n1LCRxZPhiueFGVP4dtLR6U04Y
}
on init
declare ui_knob $Volume (100000, 1000000, 1)
set_knob_unit ($Volume,$KNOB_UNIT_DB)
## -------------------------------------------------------------------------------------
# This script parses a csv file, groups customers (whom may occur more than once), based on their email.
# It attempts to include the most meaningful stem data (first name, last name etc) for each customer
# - This means taking the last value after sorting so to not use empty values, but it the same customer
# exists more than once with actual values in his stem data, it may become invalid.
# It generates a row for each customer, with their purchases listed in the same way as the input file:
# - All skus in one column, separated by a comma,
# - All order dates in one column, separated by a comma
# ... etc
# Certain columns (7-13) are skipped
@henrikj242
henrikj242 / createAttachment.cs
Last active November 29, 2018 11:55
PeytzMail Api Examples
using System;
using System.IO;
using System.Net;
namespace pmAttachment
{
class Program
{
static void Main(string[] args)
{
@henrikj242
henrikj242 / array_of.rb
Created September 6, 2018 10:49
Rspec custom matcher example
# Save this file in spec/support/matchers
RSpec::Matchers.define :be_an_array_of do |expected|
match do |actual|
actual.is_a?(Array) && actual.map(&:class) == expected
end
end
# usage:
# expect([Subscriber.new(email: 'test@example.com'), []]).to be_an_array_of([Subscriber, Array])
@henrikj242
henrikj242 / client_databases_from_bash.sh
Last active December 21, 2018 15:22
peytz_mail connecting with many things
# Use mongo console command `show databases` to get the databases and their size:
dbs=$(mongo --quiet <<EOF
show dbs
quit()
EOF
)
i=0
j=0
client_dbs=()
for db in ${dbs[*]}
require 'nokogiri'
unordered_list = <<~END
<ul>
<li>
First item
</li>
<li>
Second item
<ul>
<div class="heading-text" >
Medlemmer af en fagforening tilknyttet PlusKort får fast rabat på 17 øre pr. liter benzin og 22 øre pr. liter diesel.
Rabatterne gives altid på standerens pris og på alle Shell stationer i Danmark. Shell Card gennem PlusKort er uden
gebyr til Betalingsservice. Har du allerede et Shell Card og ønsker at få PlusKorts rabat på dit kort, skal du kontakte
Shell Card Kundeservice på 99 33 33 60 på hverdage kl. 8-17.
</div>