Skip to content

Instantly share code, notes, and snippets.

View sergenes's full-sized avatar
🏠
Working from home

Sergey Nes sergenes

🏠
Working from home
View GitHub Profile
//first
dispatch_async(queue, ^{
dispatch_group_t group1 = dispatch_group_create();
// Tasks goes here
for (NSInteger i = 0; i < 3; i++) {
@derickito
derickito / PDFViewController.swift
Last active June 5, 2023 07:03
iOS PDFKit: How to add a highlight annotation
override func viewDidLoad() {
createMenu()
}
private func createMenu() {
let highlightItem = UIMenuItem(title: "Highlight", action: #selector(highlight(_:)))
UIMenuController.shared.menuItems = [highlightItem]
}
@objc private func highlight(_ sender: UIMenuController?) {
@tasomaniac
tasomaniac / screenrecord.sh
Last active June 28, 2022 22:05 — forked from PaulKinlan/getdeviceart.sh
Screen Record for Android
#!/bin/sh
set -e
if [ -z "$1" ]; then
shot_path=$(date +%Y-%m-%d-%H-%M-%S).mp4
else
shot_path="$*"
fi
@kiichi
kiichi / ScreenshotViewController.swift
Created January 5, 2016 04:12
Example to capture the NSView screenshot in Mac App
import Cocoa
class ScreenshotViewController: NSViewController {
override func prepareForSegue(segue: NSStoryboardSegue, sender: AnyObject?) {
if let viewController = segue.destinationController as? PreviewViewController{
viewController.image = getScreenshot()
}
}
func getScreenshot() -> NSImage {
@kaloprominat
kaloprominat / xcode objective-c GCD dispatch group wait example
Last active August 5, 2023 10:50
xcode objective-c GCD dispatch group wait example
//first
dispatch_async(queue, ^{
dispatch_group_t group1 = dispatch_group_create();
// Tasks goes here
for (NSInteger i = 0; i < 3; i++) {
@stavfx
stavfx / Logger.java
Last active December 24, 2015 13:49
Android Logger class that prints out info about the calling method, just call Log.w("msg") but still get a detailed log and never forget where that log call came from :)
/**
* Created by StavFX on 10/3/13.
*/
public class Log {
private static final boolean DEBUG = true;
private static final String NEW_LINE = System.getProperty("line.separator");
public static void w(String tag, String msg) {
log(tag, msg);
}
@tedmiston
tedmiston / nodejs-tcp-example.js
Last active May 20, 2024 11:27
Node.js TCP client and server example
/*
In the node.js intro tutorial (http://nodejs.org/), they show a basic tcp
server, but for some reason omit a client connecting to it. I added an
example at the bottom.
Save the following server in example.js:
*/
var net = require('net');
@dodyg
dodyg / gist:5823184
Last active July 26, 2024 14:33
Kotlin Programming Language Cheat Sheet Part 1

#Intro

Kotlin is a new programming language for the JVM. It produces Java bytecode, supports Android and generates JavaScript. The latest version of the language is Kotlin M5.3

Kotlin project website is at kotlin.jetbrains.org.

All the codes here can be copied and run on Kotlin online editor.

Let's get started.

@nathan-osman
nathan-osman / CMakeLists.txt
Last active April 2, 2024 21:27
Generates a self-signed x509 certificate using OpenSSL.
# A simple CMake script for building the application.
cmake_minimum_required(VERSION 2.8)
project(create-x509)
# Our only dependency is OpenSSL
find_package(OpenSSL REQUIRED)
include_directories(${OPENSSL_INCLUDE_DIR})
add_executable(create-x509 create-x509.cpp)