Skip to content

Instantly share code, notes, and snippets.

View qfish's full-sized avatar
🚌

QFish qfish

🚌
View GitHub Profile
@rluvaton
rluvaton / mongo-error-code.ts
Last active October 23, 2023 06:41
Mongo Error Code #mongo #ts
export enum MongoErrorCode {
OK = 0,
InternalError = 1,
BadValue = 2,
OBSOLETE_DuplicateKey = 3,
NoSuchKey = 4,
GraphContainsCycle = 5,
HostUnreachable = 6,// Categories: NetworkError, RetriableError
HostNotFound = 7,// Categories: NetworkError, RetriableError
UnknownError = 8,
@pbakondy
pbakondy / parse-json.js
Created July 6, 2015 10:25
Parse JSON, strip BOM
// https://github.com/npm/npm/blob/master/lib/utils/parse-json.js
'use strict'
var parseJSON = module.exports = function (content) {
return JSON.parse(stripBOM(content))
}
parseJSON.noExceptions = function (content) {
try {
@ldong
ldong / download_egghead_videos.md
Last active December 7, 2023 16:16
download egghead videos

Download videos from egghead

Go to the egghead website, i.e. Building a React.js App

run

$.each($('h4 a'), function(index, video){
  console.log(video.href);
});
@alexlee002
alexlee002 / Singleton_Template.h
Last active September 20, 2015 12:32
A safe Objective-C singleton implementation. All instance method such as [[Singleton alloc] init], [[Singletion allocWithZone:zone] init]; [Singleton sharedInstance] are return the same instance and you can call them multi-times.
//
// Singleton_Template.h
//
// Created by Alex Lee on 3/11/15.
//
#undef AS_SINGLETON
#define AS_SINGLETON \
+ (instancetype)sharedInstance; \
@onevcat
onevcat / orientation-in-framework.m
Created October 28, 2014 02:43
Swizzle to solve Landscape mode in a Portrait app. Can be used in third party framework. If you are working on an app, you can only modify the app delegate to achieve it.
#pragma mark - Magic
// Need for supporting orientation when not supported in host app plist.
// Swizzle original -application:supportedInterfaceOrientationsForWindow: to change supported orientation in runtime.
-(void) swizzleSupportedInterfaceOrientationsForWindow
{
Class applicationDelegateClass = [[UIApplication sharedApplication].delegate class];
Class sdkClass = [self class];
SEL originalSelector = @selector(application:supportedInterfaceOrientationsForWindow:);
SEL swizzledSelector = @selector(las_application:supportedInterfaceOrientationsForWindow:);
@steve-jansen
steve-jansen / README.md
Last active May 21, 2024 04:59
Stop and start Symantec Endpoint Protection on OS X

This script enables you stop and start Symantec Endpoint Protection on OS X

Installation

sudo curl https://gist.githubusercontent.com/steve-jansen/61a189b6ab961a517f68/raw/sep -o /usr/local/bin/sep
sudo chmod 755 /usr/local/bin/sep
sudo chown root:staff /usr/local/bin/sep
@chriseidhof
chriseidhof / parsing.swift
Last active April 16, 2023 02:38
JSON Parsing in Swift
// This code accompanies a blog post: http://chris.eidhof.nl/posts/json-parsing-in-swift.html
//
// As of Beta5, the >>= operator is already defined, so I changed it to >>>=
import Foundation
let parsedJSON : [String:AnyObject] = [
"stat": "ok",
"blogs": [
@walesmd
walesmd / IconServiceAgent.md
Last active December 13, 2023 05:06
A lot of people are having issues with com.apple.IconServicesAgent. Since this is a very new issue, Google was no help and `man iconservicesd` is even more hilarious. I eventually fixed it, when I was working on a completely different issue (that is still not fixed). The instructions are below and on the Apple Support Forum, https://discussions.…

I was chasing down another issue (slow "Save As") and thought these two issues may have been related (with QuickLook being the common broken link). Unfortunately, my "Save As" dialog is still miserably slow on the initial load; but IconServicesAgent hasn't gone above 30MB and he rarely makes an appearance in the Console!

Some of these steps may not be necessary, but here are all of the steps I took that inadverdently put IconServicesAgent back in its place. Note: all commands are a single-line, if they appear to be multiple that's just the forum formatting.

  1. Check for any QuickLooks related .plist files. In a terminal: mdfind com.apple.quicklook. -name .plist

  2. I only had files at the system level (specifically within /System/Library/LaunchAgents/). If you have others, modify the directions below to take that into account (re-introducing plist files from the system level back up to the user).

  3. Make some temporary directories to store these plist files, just in case: mkdir ~/tmp-quicklook

@CMCDragonkai
CMCDragonkai / angularjs_directive_attribute_explanation.md
Last active November 29, 2023 15:35
JS: AngularJS Directive Attribute Binding Explanation

AngularJS Directive Attribute Binding Explanation

When using directives, you often need to pass parameters to the directive. This can be done in several ways. The first 3 can be used whether scope is true or false. This is still a WIP, so validate for yourself.

  1. Raw Attribute Strings

    <div my-directive="some string" another-param="another string"></div>
@zaach
zaach / 0_new.md
Created January 22, 2012 23:15
New Jison 0.3 features

Some improvements have been made for parser and lexer grammars in Jison 0.3 (demonstrated in the FlooP/BlooP example below.)

For lexers:

  • Patterns may use unquoted characters instead of strings
  • Two new options, %options flex case-insensitive
  • flex: the rule with the longest match is used, and no word boundary patterns are added
  • case-insensitive: all patterns are case insensitive
  • User code section is included in the generated module