Skip to content

Instantly share code, notes, and snippets.

View anvarazizov's full-sized avatar

Anvar Azizov anvarazizov

View GitHub Profile
@anvarazizov
anvarazizov / printTime.swift
Created October 13, 2017 01:03
print time in swift with milliseconds
func printDate(string: String) {
let date = Date()
let formatter = DateFormatter()
formatter.dateFormat = "HH:mm:ss.SSSS"
print(string + formatter.string(from: date))
}
@anvarazizov
anvarazizov / f3-api-example
Created May 19, 2015 07:59
Fat-free framework JSON API route example
$f3->route('GET /api/user/@id',
function($f3) {
$id = $f3->get('PARAMS.id');
header('Content-Type: application/json');
$data = array('id'=>$id, 'name'=>'Taras', 'lastname'=>'Shevchenko');
echo json_encode($data);
}
);
@anvarazizov
anvarazizov / ExportKindle.js
Created August 3, 2020 20:56 — forked from julians/ExportKindle.js
Amazon Kindle Export
/*
The following data should be run in the console while viewing the page https://read.amazon.com/
It will export a CSV file called "download" which can (and should) be renamed with a .csv extension
modified version of the original script: https://gist.github.com/jkubecki/d61d3e953ed5c8379075b5ddd8a95f22
changes:
* adds a column indicating samples (EBSP)
* updates the database version
* escapes double quotes instead of stripping them
*/
@anvarazizov
anvarazizov / coordinate_systems.swift
Created May 22, 2018 13:20 — forked from phi161/coordinate_systems.swift
Converting Between View Coordinate Systems
import UIKit
import PlaygroundSupport
class MyViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Main view
view.backgroundColor = .black
- (void)shareImageToInstagram:(UIImage *)image inView:(UIView *)view
{
NSURL * instagramURL = [NSURL URLWithString:@"instagram://"];
if ([[UIApplication sharedApplication] canOpenURL:instagramURL])
{
NSString * documentDirectory = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
NSString * saveImagePath = [documentDirectory stringByAppendingPathComponent:@"Image.igo"];
NSData * imageData = UIImagePNGRepresentation(image);
@anvarazizov
anvarazizov / example.m
Created May 21, 2015 21:07
How to see all fonts in iOS application
NSLog (@"Font families: %@", [UIFont familyNames]);
<?php
$uploaddir = './uploads/';
$file = basename($_FILES['userfile']['name']);
$uploadfile = $uploaddir . $file;
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
echo "http://iphone.zcentric.com/uploads/{$file}";
}
?>
@anvarazizov
anvarazizov / 3-wayQuickSort.m
Last active August 29, 2015 14:05
Поки що не фіналізований метод.
- (void)sortArray:(NSMutableArray *)array withLeft:(NSInteger )left andRight:(NSInteger )right
{
NSInteger i = left - 1;
NSInteger j = right;
NSInteger p = left - 1;
NSInteger q = right;
if (right <= left)
return;
@anvarazizov
anvarazizov / loop1.hs
Created July 25, 2014 12:05
My first loop in Tidal.
bps 1
d1 $ sound "[bd cp, ~ hh*2] [future hh:7/2]"
|+| pan triwave1
|+| accelerate "-1"
d2 $ every 2 (0.25 <~) $ striate 4 (sound "odx:1/2 ~ tabla:3 [feel:4]/2")
d3 $ every 4 (0.5 ~>) $ striate 2 (sound "jvbass jvbass:3 jvbass:6, jvbass:3*3")
|+| shape triwave1
@anvarazizov
anvarazizov / CustomSetter.m
Last active August 29, 2015 14:02
Custom setter features (MUST TO KNOW IT)
// Якщо ми створюємо власний сеттер і щось змінюємо в середині, то треба цю зміну дублювати у ініціалізації. Наприклад:
- (void)setFreeformGrid:(BOOL)freeformGrid
{
if (_freeformGrid != freeformGrid)
{
_freeformGrid = freeformGrid;
self.gridView.isGuidesVisible = _freeformGrid; // Цей шматок коду треба додати і в ініціалізацію, наприклад у метод - commonInit:
}
}