Skip to content

Instantly share code, notes, and snippets.

@stansidel
stansidel / NSData+Hashes.swift
Last active Mar 22, 2022
Getting MD5 and SHA256 of NSData and String in Swift
View NSData+Hashes.swift
extension NSData {
private func getHash(
algorithm: (UnsafePointer<Void>, CC_LONG, UnsafeMutablePointer<UInt8>) -> UnsafeMutablePointer<UInt8>,
digestLength: Int32
) -> String {
let digestLen = Int(digestLength)
let fileLen = CUnsignedInt(self.length)
let buffer = UnsafeMutablePointer<CUnsignedChar>.alloc(digestLen)
algorithm(self.bytes, fileLen, buffer)
@stansidel
stansidel / main.dart
Created Sep 6, 2021
Flutter Cupertino Basic Navigation
View main.dart
import 'package:flutter/cupertino.dart';
void main() {
runApp(CupertinoApp(
home: MyAppHome(), // becomes the route named '/'
routes: <String, WidgetBuilder>{
'/a': (BuildContext context) => const MyPage(title: 'page A'),
'/b': (BuildContext context) => const MyPage(title: 'page B'),
'/c': (BuildContext context) => const MyPage(title: 'page C'),
},
View gist:6c930286b67c58b0d1bd8240ca8cab50
GET /subscription/fail HTTP/1.1
Host: aa062f5____.ngrok.io
Upgrade-Insecure-Requests: 1
DNT: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36 Edg/89.0.774.68
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Sec-Fetch-Site: cross-site
Sec-Fetch-Mode: navigate
Sec-Fetch-Dest: document
Referer: https://securepay.tinkoff.ru/
View controllers.application\.js
import Controller from '@ember/controller';
export default class ApplicationController extends Controller {
appName = 'Ember Twiddle';
}
View components.simple-drag\.js
import Component from '@glimmer/component';
import { action } from '@ember/object';
import { tracked } from '@glimmer/tracking';
export default class SimpleDrag extends Component {
@tracked statusText = "";
@tracked overDropZone = false;
@action dragHasStarted() {
@stansidel
stansidel / index.html
Last active Oct 9, 2020
Independently scrollable 3-paner with a header for 2 panes
View index.html
<!DOCTYPE html>
<html>
<head>
<style>
.container {
width: 100%;
height: 100vh;
display: flex;
flex-wrap: wrap;
View assign_in_container.cpp
#include <iostream>
#include <string>
#include <utility>
#include <future>
#include <mutex>
#include <random>
#include <thread>
#include <chrono>
#include <sstream>
View properties.swift
import Foundation
class MyClass {
private let name: String
init(name: String) {
self.name = name
}
// Pure computed property, cannot be set. Behaves like a constant field for the user of the class
var computed: String {
@stansidel
stansidel / class-vs-struct.swift
Created Jun 19, 2019
Мутабельность классов и структур
View class-vs-struct.swift
class MyClass {
var name: String
init(name: String) {
self.name = name
}
}
var mc1 = MyClass(name: "Name 1")
@stansidel
stansidel / gpg-with-key
Last active Mar 9, 2019
Setting up GPG signature on Mac OS X with Xcode
View gpg-with-key
/usr/local/bin/gpg --batch --passphrase-file ~/.gnupg/key.txt --no-tty "$@"