Skip to content

Instantly share code, notes, and snippets.

@jernejstrasner
jernejstrasner / sorting.cpp
Created April 27, 2011 18:29
Various sorting algorithms in C++
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <sys/time.h>
using namespace std;
/*
Funkcije
*/
@jernejstrasner
jernejstrasner / JSSubscriptingSupport.h
Created August 11, 2012 14:47
Enable subscripting support in the iOS 5.0 SDK
//
// JSSubscriptingSupport.h
// JernejStrasner
//
// Created by Jernej Strasner on 7/27/12.
// Copyright (c) 2012 JernejStrasner.com. All rights reserved.
//
// Subscripting support for iOS SDK 5.0
//
@jernejstrasner
jernejstrasner / HMACDigest.swift
Last active May 4, 2020 14:54
HMAC digest in Swift
// Make sure you add #import <CommonCrypto/CommonCrypto.h> to the Xcode bridging header!
enum CryptoAlgorithm {
case MD5, SHA1, SHA224, SHA256, SHA384, SHA512
var HMACAlgorithm: CCHmacAlgorithm {
var result: Int = 0
switch self {
case .MD5: result = kCCHmacAlgMD5
case .SHA1: result = kCCHmacAlgSHA1
@jernejstrasner
jernejstrasner / SmoothGradientView.m
Created July 6, 2015 10:31
iOS smooth gradient using CGShading
- (void)drawRect:(CGRect)rect {
// Draw the gradient background
CGContextRef context = UIGraphicsGetCurrentContext();
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceGray();
// Define the shading callbacks
CGFunctionCallbacks callbacks = {0, blackShade, NULL};
// As input to our function we want 1 value in the range [0.0, 1.0].
// This is our position within the 'gradient'.
set -a
source $SCRIPT_INPUT_FILE_0
set +a
export PATH="$PATH:/opt/homebrew/bin"
touch $SCRIPT_OUTPUT_FILE_0
envsubst < $SCRIPT_INPUT_FILE_1 > $SCRIPT_OUTPUT_FILE_0
public struct Constants {
static let sentryDSN = "${SENTRY_DSN}"
}