Skip to content

Instantly share code, notes, and snippets.

@wongjustin99
wongjustin99 / README.md
Last active December 29, 2015 13:59 — forked from xoebus/README.md

imsg

Send iMessages from the Command Line


Install

Just run the following in your shell:

@wongjustin99
wongjustin99 / flatten.rb
Created January 7, 2018 21:37
Flatten array in Ruby
class RecursiveFlattenMethod
attr_reader :result
def flatten_nested_arrays(arr, result=[])
arr.each do |element|
if element.class != Array
result << element
else
flatten_nested_arrays(element, result)
end
@wongjustin99
wongjustin99 / slack_pac
Created March 29, 2018 03:43
Slack domains for proxy PAC file
@@||slack-msgs.com^$document
@@||slack.com^$document
brew install weechat --with-python --with-perl
pip3 install --upgrade pip setuptools
pip3 install websocket-client
mkdir -p ~/.weechat/python/autoload
wget https://raw.githubusercontent.com/wee-slack/wee-slack/master/wee_slack.py
cp wee_slack.py ~/.weechat/python/autoload

https://api.slack.com/custom-integrations/legacy-tokens

<meta name="description" content="{{ if .IsHome }}{{ .Site.Params.description }}{{ else }}{{ .Description }}{{ end }}"/>
<meta name="robots" content="noodp"/>
<link rel="canonical" href="{{ .Permalink }}" />
<!-- Twitter Card -->
<meta name="twitter:card" content="summary" />
<meta name="twitter:description" content="{{ if .IsHome }}{{ .Site.Params.description }}{{ else }}{{ .Description }}{{ end }}" />
<meta name="twitter:title" content="{{ .Title }}{{ if .IsHome }} - {{ .Site.Params.Tagline }}{{ else }} - {{ .Site.Title }}{{ end }}" />
<meta name="twitter:site" content="{{ .Site.Params.twitter }}" />
<meta name="twitter:creator" content="{{ .Site.Params.twitter }}" />
@wongjustin99
wongjustin99 / runAppleScript.swift
Created August 3, 2019 05:16
Run AppleScript from URL in swift
// need to remove extenion in XCode 10.1, or else I get weird encoding errors that corrupt the script file even when using outside of XCode
let myAppleScript = Bundle.main.url(forResource: "say_hello", withExtension: nil)!
// unnecessary catch statements/need some cleanup
func runAppleScriptFromUrl(scriptUrl: URL) {
do {
var errorScriptLoad: NSDictionary?
if let scriptObject = NSAppleScript(contentsOf: scriptUrl, error: &errorScriptLoad) {
var error: NSDictionary?
if let output: NSAppleEventDescriptor = scriptObject.executeAndReturnError(
@wongjustin99
wongjustin99 / dark_mode
Created September 8, 2019 12:31
Dark mode detection in Swift
if traitCollection.userInterfaceStyle == .light {
print(“Light”)
} else {
print(“Dark”)
}
@wongjustin99
wongjustin99 / plaintext_python3_http_server.py
Created September 9, 2019 03:07
python_http_server_with_plaintext_contenttype
#!/usr/bin/env python3
# Mostly sourced from https://stackoverflow.com/questions/37585147/unable-to-view-files-in-a-browser-with-python-http-server
from http.server import SimpleHTTPRequestHandler, test
import argparse
class InlineHandler(SimpleHTTPRequestHandler):
@wongjustin99
wongjustin99 / swiftui_url_link.swift
Created October 29, 2019 08:29
SwiftUI open URL link
@wongjustin99
wongjustin99 / v2ray.sh
Created November 20, 2019 19:07
v2ray
#!/bin/bash
red='\e[91m'
green='\e[92m'
yellow='\e[93m'
magenta='\e[95m'
cyan='\e[96m'
none='\e[0m'
_red() { echo -e ${red}$*${none}; }
_green() { echo -e ${green}$*${none}; }