Skip to content

Instantly share code, notes, and snippets.

Sean Behan seanbehan

Block or report user

Report or block seanbehan

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Desktop Uploader Ideas.md
  • Menu bar animated status icon, showing upload progress

  • Tray/opened app icon (with badge showing upload progress)

  • Share from Finder/File Explorer

  • Search for folder

  • Add new folder

  • Sync a folder (would be kind of cool)

  • Show file sizes in preview

  • animate progress bars in desktop uploader

View hello.jsx
function Hello(props){
let msg
if(props.name==="World"){
msg = <b>Hello Earth</b>
} else {
msg = <i>{props.name}</i>
}
return (
<div>
@seanbehan
seanbehan / node-walk.js
Created Nov 19, 2018 — forked from lovasoa/node-walk.js
Walk through a directory recursively in node.js.
View node-walk.js
var fs = require("fs"),
path = require("path");
function walk(dir, callback) {
fs.readdir(dir, function(err, files) {
if (err) throw err;
files.forEach(function(file) {
var filepath = path.join(dir, file);
fs.stat(filepath, function(err,stats) {
if (stats.isDirectory()) {
@seanbehan
seanbehan / url-params-extension.swift
Created Sep 23, 2018
parse url params in swift with an extension
View url-params-extension.swift
extension URL {
// Usage:
// URL(string:"http://.../?x=1&y=2").params()
func params() -> [String:Any] {
var dict = [String:Any]()
if let components = URLComponents(url: self, resolvingAgainstBaseURL: false) {
if let queryItems = components.queryItems {
for item in queryItems {
@seanbehan
seanbehan / basic_auth_with_alamofire.swift
Last active Sep 14, 2018
basic auth with alamofire in swift
View basic_auth_with_alamofire.swift
import Alamofire
let url = "https://example.com/"
let user = "me"
let pass = "pwd"
let headers: HTTPHeaders = [
"Authorization": "Basic " + ("\(user):\(pass)".data(using:.utf8)?.base64EncodedString() ?? ""),
]
@seanbehan
seanbehan / wordpress-post-tags-and-categories.sql
Created Sep 13, 2018
get list of wordpress post tags and taxonomies
View wordpress-post-tags-and-categories.sql
select x.taxonomy, left(t.name, 50) name, left(p.post_title, 50) post_title from
wp_terms t,
wp_term_taxonomy x,
wp_term_relationships r,
wp_posts p
where
t.term_id = x.term_id
and
x.term_taxonomy_id = r.term_taxonomy_id
@seanbehan
seanbehan / emojis.csv
Created Jul 19, 2018
csv of emojis w/ invalids removed
View emojis.csv
😀 grinning face
😁 beaming face with smiling eyes
😂 face with tears of joy
🤣 rolling on the floor laughing
😃 grinning face with big eyes
😄 grinning face with smiling eyes
😅 grinning face with sweat
😆 grinning squinting face
😉 winking face
😊 smiling face with smiling eyes
@seanbehan
seanbehan / Reachability.swift
Created Jun 7, 2018
Reachability.swift class for detecting if network connection is available
View Reachability.swift
import Cocoa
import SystemConfiguration
// Usage
// if Reachability.isConnectedToNetwork() {
// print("We're online!")
// }
public class Reachability {
class func isConnectedToNetwork() -> Bool {
View read-write-directory-permissions.swift
guard let window = view.window else { print("Nope") ; return }
let panel = NSOpenPanel()
panel.canChooseFiles = false
panel.canChooseDirectories = true
panel.allowsMultipleSelection = false
panel.canCreateDirectories = true
panel.beginSheetModal(for: window) { (result) in
if result == NSFileHandlingPanelOKButton {
self.folderPath = panel.urls[0]
}
View io.swift
// Save data to file
let fileName = "Test"
let DocumentDirURL = try! FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: true)
let fileURL = DocumentDirURL.appendingPathComponent(fileName).appendingPathExtension("txt")
print("FilePath: \(fileURL.path)")
let writeString = "Write this text to the fileURL as text in iOS using Swift"
do {
// Write to the file
You can’t perform that action at this time.