Skip to content

Instantly share code, notes, and snippets.

View madson's full-sized avatar
👨‍💻
Always coding

Madson Mac madson

👨‍💻
Always coding
View GitHub Profile
var express = require('express')
var bodyParser = require('body-parser')
var app = express()
// parse application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({ extended: false }))
// parse application/json
app.use(bodyParser.json())
@madson
madson / draw grid.html
Created October 8, 2019 00:40
Draw grid using canvas
<html>
<head>
<style>
* { margin: 0px; padding: 0px; }
#imgGrid { position: absolute; top: 0; left: 0; z-index: 0; opacity: 1; }
#myCanva { position: absolute; top: 0; left: 0; z-index: 999; opacity: 0.5; }
img { object-fit: contain; width: 1000px; height: auto; }
</style>
</head>
<body>
import Foundation
var input = readLine()!
let upperCaseLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
var count = 1
for letter in input.characters {
if upperCaseLetters.contains(String(letter)) {
import Foundation
var text = "baabc"
func removeDuplicatedCharacters(in text: String) -> String {
var other = text
var uniqueChars = [String]()
for char in other.characters {
let current = char.description
import Foundation
extension String {
var sortedChars: String {
get {
var current = ""
self.sorted().forEach {
if $0 != " " {
current.append($0)
import Foundation
import UIKit
extension UIView {
var allSubviews: [UIView] {
get {
var viewsFound: [UIView] = [UIView]()
return viewsFound
}
}
@madson
madson / ProgressBubble.swift
Created December 16, 2016 17:56
UIView with a rounded progress border
class ProgressBubble : UIView {
var startAngle: Double = 90
var lineWidth: CGFloat = 4
var timer: Timer!
var borderColor: UIColor = UIColor(colorLiteralRed: 248/255.0, green: 141/255.0, blue: 2/255.0, alpha: 1)
override func draw(_ rect: CGRect) {
self.drawBorder(rect, self.startAngle, self.borderColor)
}
excluded: # paths to ignore during linting. Takes precedence over `included`.
- Carthage
- Pods
line_length: 120
disabled_rules:
- trailing_whitespace
force_cast: warning
force_try:
severity: warning
type_name:
@madson
madson / add_launchd_to_tcc.sh
Last active August 29, 2015 14:26 — forked from mtauraso/add_launchd_to_tcc.sh
TCC Database Script
#!/bin/bash
# This will add lauchd to the list of allowed processes for accessibility access
sudo sqlite3 /Library/Application\ Support/com.apple.TCC/TCC.db "INSERT or REPLACE INTO access VALUES('kTCCServiceAccessibility','/sbin/osascript',1,1,1,NULL)"
# This outputs the rows in the TCC database
sudo sqlite3 /Library/Application\ Support/com.apple.TCC/TCC.db 'select * from access'
echo "Restart is required for these changes to take effect"
- (void)waitSignal
{
while (dispatch_semaphore_wait(_internalSemaphore, DISPATCH_TIME_NOW))
{
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode
beforeDate:[NSDate dateWithTimeIntervalSinceNow:10]];
}
}