Skip to content

Instantly share code, notes, and snippets.

@Krishna
Krishna / clapperboard.js
Created April 23, 2020 13:03 — forked from pragdave/clapperboard.js
Trivial JS function to help sync sound and screen when recording a browser based screencast
export function clapperBoard() {
let audio = new AudioContext()
let beep = audio.createOscillator()
let flash = document.createElement("div")
beep.frequency.value = 440 * 5
beep.connect(audio.destination)
flash.classList.add("clapperboard")
beep.start()
@Krishna
Krishna / api_controller.rb
Created May 17, 2020 02:48 — forked from eliotsykes/api_controller.rb
Token Authentication in Rails API Controller and Request Spec
# File: app/controllers/api/api_controller.rb
class Api::ApiController < ActionController::Base
# Consider subclassing ActionController::API instead of Base, see
# http://api.rubyonrails.org/classes/ActionController/API.html
protect_from_forgery with: :null_session
before_action :authenticate
def self.disable_turbolinks_cookies
skip_before_action :set_request_method_cookie
@Krishna
Krishna / String+EmojiCheck.swift
Last active June 22, 2020 14:48 — forked from krummler/String+EmojiCheck.swift
Emoji Checking for Swift 5.0 and up
import Foundation
// Source: https://stackoverflow.com/a/39425959
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.properties.isEmoji && firstScalar.value > 0x238C
}
@Krishna
Krishna / Calendar.swift
Created July 2, 2020 23:50 — forked from mecid/Calendar.swift
Calendar view in SwiftUI
import SwiftUI
fileprivate extension DateFormatter {
static var month: DateFormatter {
let formatter = DateFormatter()
formatter.dateFormat = "MMMM"
return formatter
}
static var monthAndYear: DateFormatter {
@Krishna
Krishna / LearnGoIn5mins.md
Last active January 4, 2021 19:17 — forked from prologic/LearnGoIn5mins.md
Learn Go in ~5mins