Skip to content

Instantly share code, notes, and snippets.

@thewheat
thewheat / annotatorjs.php
Last active June 6, 2020 06:36
Demo file of http://annotatorjs.org/ that allows saving of annotations in a simple text file
<?php
define("ANNOTATIONS_FILE", "annotations.json");
$annotations = getAnnotations();
if (!$_GET || !$_GET['action']){
}
else if ($_GET['action'] == "search") {
$uri = $_GET['uri'];
@thewheat
thewheat / screen_tmux.md
Last active March 18, 2021 07:38
Commands for screen/tmux

screen

  • Ctrl + a, c: create new screen
  • Ctrl + a, a: switch to previous screen
  • Ctrl + a, ": list all screens
  • Ctrl + a, NumberX : switch to screen #NumberX
  • screen -ls: list all sessions
  • screen -rad ID: reattach

tmux

Panes

# Quick start for youtube-dl
- https://github.com/ytdl-org/youtube-dl/
## Default usage
youtube-dl URL
## Download certain resolution
youtube-dl -f "best[height<=480]" URL
## Download certain extension
@thewheat
thewheat / brunei_postcodes.csv
Last active September 2, 2019 07:21
Brunei Postcodes extracted from http://www.post.gov.bn/SitePages/postcodes.aspx There are some without postcodes due to the server not returning any data. If you need to know which Mukim/ Kampong you're located in https://thewheat.github.io/brunei_map/ could be useful
Number District Mukim Kampong Code
95 Brunei-Muara Daerah Brunei Dan Muara Peti Surat 01 hingga 500 BS8670
97 Brunei-Muara Daerah Brunei Dan Muara Peti Surat 1001 hingga 1500 BS8672
98 Brunei-Muara Daerah Brunei Dan Muara Peti Surat 1501 hingga 2000 BS8673
99 Brunei-Muara Daerah Brunei Dan Muara Peti Surat 2001 hingga 2500 BS8674
100 Brunei-Muara Daerah Brunei Dan Muara Peti Surat 2501 BS8675
96 Brunei-Muara Daerah Brunei Dan Muara Peti Surat 501 hingga 1000 BS8671
107 Brunei-Muara Daerah Brunei Dan Muara Peti Surat Persendirian (Pejabat Pos Anggerek Desa) BB3713
102 Brunei-Muara Daerah Brunei Dan Muara Peti Surat Persendirian (Pejabat Pos Gadong) BE3978
108 Brunei-Muara Daerah Brunei Dan Muara Peti Surat Persendirian (Pejabat Pos Limau Manis) BH2323
@thewheat
thewheat / ffmpeg.md
Last active March 8, 2020 06:29
Document typical ffmpeg commands I use

Extract only video from file

ffmpeg -i input.mov -c:v copy -an input_video.mov

Extract only audio from file

ffmpeg -i input.mov -c:a copy -vn input_audio.aac
@thewheat
thewheat / Intercom Encrypted Mode.md
Last active March 21, 2021 19:05
Sample code to enable Intercom Encrypted Mode
<script>
var APP_ID = "YOUR_APP_ID";
window.intercomSettings = {
app_id: APP_ID
};
</script>
<script>(function(){var w=window;var ic=w.Intercom;if(typeof ic==="function"){ic('reattach_activator');ic('update',intercomSettings);}else{var d=document;var i=function(){i.c(arguments)};i.q=[];i.c=function(args){i.q.push(args)};w.Intercom=i;function l(){var s=d.createElement('script');s.type='text/javascript';s.async=true;s.src='https://widget.intercom.io/widget/' + APP_ID;var x=d.getElementsByTagName('script')[0];x.parentNode.insertBefore(s,x);}if(w.attachEvent){w.attachEvent('onload',l);}else{w.addEventListener('load',l,false);}}})()</script>
@thewheat
thewheat / intercom_with_shopify.js
Last active July 30, 2021 14:35
Integrate Intercom https://intercom.com into Shopify via manual code. Supports both visitors and logged in users
<script>
// Add this to your theme layout code after the footer
var APP_ID = "YOUR_APP_ID";
{% if customer %}
// https://help.shopify.com/en/themes/liquid/objects/customer
window.intercomSettings = {
app_id: APP_ID,
name: "{{customer.name}}",
email: "{{customer.email}}",
@thewheat
thewheat / intercom_javascript_attributes.md
Last active May 11, 2021 15:13
Attributes for Intercom's client side Javascript integration used when installing the messenger https://developers.intercom.com/docs/js-installation

Javascript Installation Attributes

  • Intercom can be initialised with various ways For visitors
window.intercomSettings = { 
  app_id: YOUR_APP_ID
}

For Logged in users

<?php
$random = rand();
$date = date('Y-m-d H:i:s');
$report_to_file = true;
$report_page = "./csp.php?report=1";
$report_file_name = "report.txt";
$intercom_app_id = "YOUR_APP_ID";