Skip to content

Instantly share code, notes, and snippets.

View Dev1an's full-sized avatar

Damiaan Dufaux Dev1an

View GitHub Profile
@ishikawa
ishikawa / MyTextView.h
Created November 8, 2008 03:24
The simple custom text view (Mac OS X/Cocoa)
#import <Cocoa/Cocoa.h>
@interface MyTextView : NSView {
NSMutableAttributedString *_text;
}
@end
@natecook1000
natecook1000 / NSTimer+Closure.swift
Last active July 12, 2024 05:11
Scheduled NSTimer with a Swift closure
extension NSTimer {
/**
Creates and schedules a one-time `NSTimer` instance.
- Parameters:
- delay: The delay before execution.
- handler: A closure to execute after `delay`.
- Returns: The newly-created `NSTimer` instance.
*/
@duvrai
duvrai / errors.php
Created July 2, 2015 14:58
Mailjet errors
$internalErrors = array(
'MJ01' => 'Could not determine APIKey', // SERRCouldNotDetermineAPIKey
'MJ02' => 'No persister object found for class: "%s"', // SErrNoPersister
'MJ03' => 'A non-empty value is required', // SErrValueRequired
'MJ04' => 'Value must have at least length %d', // SErrMinLength
'MJ05' => 'Value may have at most length %d', // SErrMaxLength
'MJ06' => 'Value must be larger than or equal to %s', // SErrMinValue
'MJ07' => 'Value must be less than or equal to %s', // SErrMaxValue
'MJ08' => 'Property %s is invalid: %s', // SErrInProperty
'MJ09' => 'Value is not in list of allowed values: (%s)', // SErrValueNotInList
@deanrad
deanrad / artillery-meteor.yml
Created May 15, 2017 16:16
Load Test Meteor with Artillery (http://artillery.io)
config:
# target: "ws://localhost:3000/websocket"
target: "wss://deployed-server/websocket"
phases:
-
duration: 60
arrivalRate: 10
ws:
# Ignore SSL certificate errors
# - useful in *development* with self-signed certs
@SanCoder-Q
SanCoder-Q / synology.startup
Created December 25, 2017 14:29
Synology NAS - How to make a program run at startup
Synology NAS - How to make a program run at startup
The other day I created a little node.js project to keep track of some finances. Synology has a node.js package but that just installs the tools - it has no 'container' or any other support to drop files and have it run automagically. Maybe one day.
In the meantime, you can start your project when you SSH into the NAS. My project has a 'www' script which bootstraps my project, so to start I simply type 'node bin/www' from the project directory. But, it only runs while I'm logged in, and if I log out for any reason, the process dies. That's hardly useful when I'm away from home, or on a different PC. So I decided to have a look at starting my project as a Linux service.
After doing a lot of research into how Synology does services, and a few failed attempts at init scripts, I found that Synology DSM (since version 5 perhaps) bundles Upstart, which is a neat little tool to deal with services on Linux. It's most prevalent on Debian and derivatives (notably Ub
@rodydavis
rodydavis / AutoIncrementBuilds.sh
Last active September 15, 2018 08:34
Auto Increment Build and Version Numbers
#Works with Xcode 9 (Confirmed)
#1. Go to "Edit Schemes"
#2. Go to "Build"
#3. Go to "Pre-Actions"
#4. Select YOUR app in "Provide Build Settings from:"
#5. Paste Below Script in Box
#6. Build Project
#Build Number ++
func zalgo(_ string: String, intensity: Int = 5) -> String {
let combiningDiacriticMarks = 0x0300...0x036f
let latinAlphabetUppercase = 0x0041...0x005a
let latinAlphabetLowercase = 0x0061...0x007a
var output: [UnicodeScalar] = []
for scalar in string.unicodeScalars {
output.append(scalar)
guard (latinAlphabetUppercase).contains(numericCast(scalar.value)) ||
(latinAlphabetLowercase).contains(numericCast(scalar.value))
//
// AppDelegate.swift
// UDPTest
//
// Created by Paul Wilkinson on 22/10/19.
// Copyright © 2019 Paul Wilkinson. All rights reserved.
//
import Cocoa
import SwiftUI