Skip to content

Instantly share code, notes, and snippets.

@dinnouti
dinnouti / unbound.conf
Created June 28, 2023 20:13
unbound configuration for ubuntu 22.04
server:
tls-cert-bundle: /etc/ssl/certs/ca-certificates.crt
qname-minimisation: yes
interface: eth0
access-control: 192.168.0.0/16 allow
logfile: "/var/log/unbound.log"
use-syslog: no
do-ip6: no
prefetch: yes
cache-max-ttl: 14400
@dinnouti
dinnouti / redshift_show_schema.sql
Last active June 10, 2020 20:19
Redshift - Listing tables, views, columns from database information schema
SELECT
t.table_schema
, t.table_name
, c.column_name
, c.data_type
, CASE
WHEN c.character_maximum_length IS NOT NULL THEN c.character_maximum_length
ELSE c.numeric_precision
END AS max_length
, is_nullable
@dinnouti
dinnouti / concat.sh
Created June 6, 2020 14:40
Concatenating mp3 and sampling with lame
find . -iname '*.mp3' -print0 | sort -zn | xargs -0 -I '{}' lame --decode '{}' | lame --tt "Title" --ta "Artist" --tl "Title" -b 32 - concat2.mp3
@dinnouti
dinnouti / string_to_float.py
Created January 28, 2020 15:10
Python convert string with non-digits characters to float
df['Total $'].replace('[^.0-9]', '', regex=True).astype(float)
@dinnouti
dinnouti / ip.py
Created December 9, 2019 17:58
Show IP address in Jupyter notebook
import socket
print('host name', socket.gethostname())
print('host ip adddress', socket.gethostbyname(socket.gethostname()))
@dinnouti
dinnouti / copy_url_as_markdown.js
Last active January 30, 2020 22:02
Copy URL as Markdown as a browser bookmark
// Chrome version
javascript: (function() {
let text = '[' + document.title + '](' + location.href + ')';
navigator.clipboard.writeText(text)
.then(() => {
console.log('Text copied to clipboard: ', text);
})
.catch(err => {
console.error('Could not copy text: ', err);
});
@dinnouti
dinnouti / count_commas.py
Created April 14, 2019 17:08
count the number of commas in a file and print if the number of commas is different than expected. useful for csv files where each row could have different number of commas breaking an import.
# count the number of commas in a file and print if the number of commas is different than expected
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("filename", help="filename")
parser.add_argument("commas", help="number of expected commas", type=int)
args = parser.parse_args()
file = args.filename
number_commas = int(args.commas)
@dinnouti
dinnouti / sf.php
Created April 2, 2017 00:53
Using Salesforce SOQL query services and PHP Curl library
<?php
$sf_config = array(
client_id => '', // from salesforce OAuth configuration (add new app ...)
client_secret => '',
username => '', // username login to salesforce
password => '', // no need to concat password token
url => 'https://login.salesforce.com/services/oauth2/token',
grant_type => 'password',
query_srv_url => '/services/data/v20.0/query/'
@dinnouti
dinnouti / jsforce_vue.js
Last active September 6, 2016 20:02
Example in how to use jsforce () and vue.js (). I choose not to be right in terms of pattern in lieu of didactic.
<apex:page standardController="Account" showHeader="false" sidebar="false" standardStylesheets="false">
<script src="//cdnjs.cloudflare.com/ajax/libs/jsforce/1.7.0/jsforce.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/vue/1.0.26/vue.js"></script>
<h1>Using jsforce and Vue Js</h1>
<div id="app">
<label>
Filter by name:
<input v-model="name" />
@dinnouti
dinnouti / GetItems.ps1
Created June 3, 2016 18:08
Read items from SharePoint Online in Powershell
#Sample provided As-Is – Use after sufficient testing.
#replace these details – User name, domain, Password. (Also consider using Get-Credential to enter password securely as script runs)
#Ensure there is a folder called C:\OUTPUT
#from https://blogs.technet.microsoft.com/sharepointrecipes/2015/06/17/code-sample-spo-dump-out-list-items-to-csv/
$username = "admin@domain.onmicrosoft.com"
$password = "pwd"
$url = "https://domain.sharepoint.com"