Skip to content

Instantly share code, notes, and snippets.

View bibhas's full-sized avatar

Bibhas Acharya bibhas

  • Kathmandu, Nepal
View GitHub Profile
@bibhas
bibhas / Keycodes.swift
Created December 21, 2021 10:08 — forked from swillits/Keycodes.swift
Swift Keyboard Keycodes
struct Keycode {
// Layout-independent Keys
// eg.These key codes are always the same key on all layouts.
static let returnKey : UInt16 = 0x24
static let enter : UInt16 = 0x4C
static let tab : UInt16 = 0x30
static let space : UInt16 = 0x31
static let delete : UInt16 = 0x33
static let escape : UInt16 = 0x35
@bibhas
bibhas / gist:3f8d7f98c6f9b402e3f2bbe515d7d1bd
Created June 29, 2020 09:03 — forked from paulmelnikow/gist:4645764
Working Objective-C keychain library
NSString *const kKeychainErrorDomain = @"kKeychainErrorDomain"
NSString * ServiceName = @"My Service";
+ (NSError *) errorWithStatus:(OSStatus) status {
if (errSecSuccess == status) return nil;
#if __has_feature(objc_arc)
NSString *message = (__bridge_transfer NSString *)SecCopyErrorMessageString(status, NULL);
#else
NSString *message = [(id) SecCopyErrorMessageString(status, NULL) autorelease];
#import <Foundation/Foundation.h>
static const uint8_t huffman_table[] =
{
0xFF, 0xC4, 0x01, 0xA2, 0x00, 0x00, 0x01, 0x05, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02,
0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x01, 0x00, 0x03,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,
0x0A, 0x0B, 0x10, 0x00, 0x02, 0x01, 0x03, 0x03, 0x02, 0x04, 0x03, 0x05,
let startLocations: [NSNumber] = [ 0.0, 0.05, 0.25, 0.3]
let endLocations: [NSNumber] = [ 0.7, 0.75, 0.95, 1]
gradient.startPoint = CGPoint(x: -0, y: 0.5)
gradient.endPoint = CGPoint(x: 1, y: 0.5)
gradient.colors = [ UIColor.white.cgColor, UIColor.tetraDarkBlue.cgColor, UIColor.tetraDarkBlue.cgColor, UIColor.white.cgColor ]
gradient.locations = startLocations
layer.insertSublayer(gradient, at: 0)
-(void) addAppAsLoginItem {
if ([self wasAppAddedAsLoginItem]) return;
NSString * appPath = [[NSBundle mainBundle] bundlePath];
// This will retrieve the path for the application
// For example, /Applications/test.app
CFURLRef url = (__bridge CFURLRef)[NSURL fileURLWithPath:appPath];
// Create a reference to the shared file list.
// $base-font-size: 16px; // not sure this ever did anything
$base-line-height: 1.5;
// this value may vary for each font
// unitless value relative to 1em
$cap-height: 0.68;
@mixin baseline($font-size, $scale: 2) {
@bibhas
bibhas / _baseline.scss
Created January 26, 2018 05:38 — forked from razwan/_baseline.scss
Aligning type to baseline the right way with SASS
$base-font-size: 16px;
$base-line-height: 1.5;
// this value may vary for each font
// unitless value relative to 1em
$cap-height: 0.68;
@mixin baseline($font-size, $scale: 2) {
@bibhas
bibhas / AppDelegate.m
Created December 13, 2017 11:29 — forked from mattrajca/AppDelegate.m
MetalComputeOSX
//
// AppDelegate.m
// MetalComputeOSX
//
#import "AppDelegate.h"
@import Metal;
#define IMAGE_SIZE 128
@bibhas
bibhas / libyuv.cc
Created November 11, 2017 09:56 — forked from zintus/libyuv.cc
Update CVImageBufferRef with pixels in capture format with bgra pixels using libyuv
// Function to update image buffer in NV12 format with BGRA pixel buffer
// Assumptions:
// bgra buffer is 32bpp
// bgra buffer width and height equal to imageBuffer
// bgra buffer stride is equal to imageBuffer width
int UpdateSampleBufferWithBGRAPixels(CVImageBufferRef imageBuffer, void *bgraPixels) {
const OSType pixelFormat = CVPixelBufferGetPixelFormatType(imageBuffer);
assert(pixelFormat == kCVPixelFormatType_420YpCbCr8BiPlanarFullRange || pixelFormat == kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange);
const size_t width = CVPixelBufferGetWidth(imageBuffer);
@bibhas
bibhas / CGSPrivate.h
Created August 12, 2017 05:44 — forked from rjw57/CGSPrivate.h
CGSPrivate.h - undocumented APIs for OSX. Re-licensed under MIT licence.
/* CGSPrivate.h -- Header file for undocumented CoreGraphics stuff. */
/* This file is a relicensed portion of DesktopManager and was originally released under
* the terms of the GNU General Public Licence. Original licence text follows the new terms.
* The contents of this file has been re-released by the original author under the following terms:
*
* Copyright (C) 2003, 2004, 2013 Richard J Wareham <richwareham@users.sourceforge.net>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this
* software and associated documentation files (the "Software"), to deal in the Software