Skip to content

Instantly share code, notes, and snippets.

View drinkius's full-sized avatar

Alexander Telegin drinkius

View GitHub Profile
@drinkius
drinkius / .deps...npm...@openzeppelin...contracts...security...ReentrancyGuard.sol
Created April 20, 2022 22:27
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.6.9+commit.3e3065ac.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)
pragma solidity ^0.8.0;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
@drinkius
drinkius / .deps...npm...@openzeppelin...contracts...security...ReentrancyGuard.sol
Created February 17, 2022 19:49
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.5.16+commit.9c3226ce.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)
pragma solidity ^0.8.0;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
@drinkius
drinkius / rename.js
Created December 3, 2021 20:13 — forked from scriptex/rename.js
Rename all files in a folder with NodeJS
const { join } = require('path');
const { readdirSync, renameSync } = require('fs');
const [dir, search, replace] = process.argv.slice(2);
const match = RegExp(search, 'g');
const files = readdirSync(dir);
files
.filter(file => file.match(match))
.forEach(file => {
const filePath = join(dir, file);
@drinkius
drinkius / ContentView.swift
Created May 12, 2020 22:13 — forked from shawnthroop/ContentView.swift
A UIScrollView but SwiftUI
import SwiftUI
struct ContentView: View {
@State private var bounds: Bounds = .zero
var body: some View {
VStack {
controls
scrollArea
@drinkius
drinkius / ContentView.swift
Created May 12, 2020 22:13 — forked from shawnthroop/ContentView.swift
A UIScrollView but SwiftUI
import SwiftUI
struct ContentView: View {
@State private var bounds: Bounds = .zero
var body: some View {
VStack {
controls
scrollArea
Process: Telegram [1693]
Path: /private/var/folders/*/Telegram.app/Contents/MacOS/Telegram
Identifier: ru.keepcoder.Telegram
Version: 5.7 (181147)
Code Type: X86-64 (Native)
Parent Process: ??? [1]
Responsible: Telegram [1693]
User ID: 501
Date/Time: 2019-09-15 13:55:35.657 +0300
Process: Telegram [1297]
Path: /Applications/Telegram.app/Contents/MacOS/Telegram
Identifier: ru.keepcoder.Telegram
Version: 5.6.1 (179691)
App Item ID: 747648890
App External ID: 832350520
Code Type: X86-64 (Native)
Parent Process: ??? [1]
Responsible: Telegram [1297]
User ID: 501
var mediaJSON = { "categories" : [ { "name" : "Movies",
"videos" : [
{ "description" : "Big Buck Bunny tells the story of a giant rabbit with a heart bigger than himself. When one sunny day three rodents rudely harass him, something snaps... and the rabbit ain't no bunny anymore! In the typical cartoon tradition he prepares the nasty rodents a comical revenge.\n\nLicensed under the Creative Commons Attribution license\nhttp://www.bigbuckbunny.org",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" ],
"subtitle" : "By Blender Foundation",
"thumb" : "images/BigBuckBunny.jpg",
"title" : "Big Buck Bunny"
},
{ "description" : "The first Blender Open Movie from 2006",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4" ],
@drinkius
drinkius / RepeatingTimer.swift
Created November 20, 2018 16:48 — forked from danielgalasko/RepeatingTimer.swift
A repeating GCD timer that can run on a background queue
/// RepeatingTimer mimics the API of DispatchSourceTimer but in a way that prevents
/// crashes that occur from calling resume multiple times on a timer that is
/// already resumed (noted by https://github.com/SiftScience/sift-ios/issues/52
class RepeatingTimer {
let timeInterval: TimeInterval
init(timeInterval: TimeInterval) {
self.timeInterval = timeInterval
}
@drinkius
drinkius / UIView+AutoLayout.swift
Created November 20, 2018 11:48 — forked from danielgalasko/UIView+AutoLayout.swift
A UIView extension for common auto layout constraints
extension UIView {
func addConstaintsToPinHorizontalEdgesToSuperView(padding: CGFloat = 0) {
prepareForConstraints()
self.superview!.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|-(padding)-[view]-(padding)-|",
options: NSLayoutFormatOptions(0),
metrics: ["padding":padding],
views: ["view":self]))
}
func addConstaintsToPinVerticalEdgesToSuperView(padding: CGFloat = 0) {