Skip to content

Instantly share code, notes, and snippets.


Krishna Krishna

View GitHub Profile
Krishna /
Last active Jan 4, 2021 — forked from prologic/
Learn Go in ~5mins
Krishna / Calendar.swift
Created Jul 2, 2020 — forked from mecid/Calendar.swift
Calendar view in SwiftUI
View Calendar.swift
import SwiftUI
fileprivate extension DateFormatter {
static var month: DateFormatter {
let formatter = DateFormatter()
formatter.dateFormat = "MMMM"
return formatter
static var monthAndYear: DateFormatter {
Krishna / String+EmojiCheck.swift
Last active Jun 22, 2020 — forked from krummler/String+EmojiCheck.swift
Emoji Checking for Swift 5.0 and up
View String+EmojiCheck.swift
import Foundation
// Source:
extension Character {
/// A simple emoji is one scalar and presented to the user as an Emoji
var isSimpleEmoji: Bool {
guard let firstScalar = unicodeScalars.first else { return false }
return && firstScalar.value > 0x238C
Krishna / api_controller.rb
Created May 17, 2020 — forked from eliotsykes/api_controller.rb
Token Authentication in Rails API Controller and Request Spec
View api_controller.rb
# File: app/controllers/api/api_controller.rb
class Api::ApiController < ActionController::Base
# Consider subclassing ActionController::API instead of Base, see
protect_from_forgery with: :null_session
before_action :authenticate
def self.disable_turbolinks_cookies
skip_before_action :set_request_method_cookie
Krishna / clapperboard.js
Created Apr 23, 2020 — forked from pragdave/clapperboard.js
Trivial JS function to help sync sound and screen when recording a browser based screencast
View clapperboard.js
export function clapperBoard() {
let audio = new AudioContext()
let beep = audio.createOscillator()
let flash = document.createElement("div")
beep.frequency.value = 440 * 5
Krishna /
Created Mar 10, 2020 — forked from tclementdev/
Making efficient use of the libdispatch (GCD)

libdispatch efficiency tips

I suspect most developers are using the libdispatch inefficiently due to the way it was presented to us at the time it was introduced and for many years after that, and due to the confusing documentation and API. I realized this after reading the 'concurrency' discussion on the swift-evolution mailing-list, in particular the messages from Pierre Habouzit (who is the libdispatch maintainer at Apple) are quite enlightening (and you can also find many tweets from him on the subject).

My take-aways are:


Cheat Sheet: Simple Authentication in Rails 5 with has_secure_password

The goal of this cheatsheet is to make it easy to add hand-rolled authentication to any rails app in a series of layers.

First the simplest/core layers, then optional layers depending on which features/functionality you want.

AUTHOR Ira Herman
LANGUAGE/STACK Ruby on Rails Version 4 or 5
Krishna / cli-nsrunloop.m
Created Jun 13, 2018 — forked from syzdek/cli-nsrunloop.m
Creating an NSRunLoop for a command line utility.
View cli-nsrunloop.m
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[])
NSRunLoop * runLoop;
CLIMain * main; // replace with desired class
// create run loop
Krishna / SafeSet.m
Created Jun 13, 2018 — forked from ridiculousfish/SafeSet.m
A thread safe set written in Objective-C
View SafeSet.m
#import <Foundation/Foundation.h>
@interface SafeSet : NSObject {
NSMutableSet *set;
dispatch_queue_t queue;
@implementation SafeSet
View gist:0d06a6251501ee0f6f5472d4f65ad44e
Copyright (C) 2016 Apple Inc. All Rights Reserved.
See LICENSE.txt for this sample’s licensing information
`DirectoryMonitor` is used to monitor the contents of the provided directory by using a GCD dispatch source.
import Foundation