Skip to content

Instantly share code, notes, and snippets.

View fnc12's full-sized avatar
😈

Yevgeniy Zakharov fnc12

😈
View GitHub Profile
@Nekrolm
Nekrolm / move_the_vector.md
Created January 14, 2024 00:05
How to move vectors of different types

Как перекладывают вектора

При работе над разными числодробилками, анализирующими последовательности, применяющими фильтры к картинкам, cчитающим свертки и проч, периодически возникает необходимость преобразовать массив целых чисел в массив чисел с плавающей точкой и наоборот.

На C++ это может выглядеть так

std::vector<float> to_floats(std::vector<int> input) {
    std::vector<float> result(input.size());
    std::transform(begin(input), end(input), begin(result), [](int x) -> float { return x; });
@diegopacheco
diegopacheco / bazel-ubuntu-20.04.md
Created December 4, 2020 17:41
Installing Google Bazel on Ubuntu 20.04 LTS
sudo apt install curl gnupg
curl -fsSL https://bazel.build/bazel-release.pub.gpg | gpg --dearmor > bazel.gpg
sudo mv bazel.gpg /etc/apt/trusted.gpg.d/
echo "deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list

sudo apt update && sudo apt install bazel
sudo apt update && sudo apt full-upgrade
bazel --version
@foxicode
foxicode / DatePickerPopup.swift
Created September 13, 2020 06:32
Popup view with UIDatePicker (Swift, iOS)
import UIKit
import SnapKit
class DatePickerPopup: UIView {
private var frameView: UIView!
private var titleLabel: UILabel!
private var datePicker: UIDatePicker!
private var okButton: UIButton!
private var cancelButton: UIButton!
@abhi21git
abhi21git / ExtensionURLRequest.swift
Last active February 19, 2024 12:23
Swift cURL Printer
//
// ExtensionURLRequest.swift
//
// Created by Abhishek Maurya on 16/07/20.
// Copyright © 2020. All rights reserved.
//
import Foundation
extension URLRequest {
extension Sequence {
func countIf( predicate: (Self.Iterator.Element) -> Bool ) -> Int {
return reduce( 0 ) { predicate($1) ? $0+1 : $0 }
}
}
@ClaudeSutterlin
ClaudeSutterlin / UIImageFixedOrientationExtension.swift
Last active September 12, 2018 12:52 — forked from schickling/UIImageFixedOrientationExtension.swift
[Swift3] Extension to fix orientation of an UIImage (Sets orientation to portrait)
extension UIImage {
func fixedOrientation() -> UIImage {
if imageOrientation == .up {
return self
}
var transform: CGAffineTransform = CGAffineTransform.identity
@marteinn
marteinn / progamatically-popover-example.m
Last active January 15, 2022 12:13
NSPopover Example: Create and show a NSPopover programmatically when a user clicks a button in a subview
-(void) buttonClick:(NSButton *)sender {
// Create view controller
EXPopoverViewController *viewController = [[EXPopoverViewController alloc] init];
// Create popover
NSPopover *entryPopover = [[NSPopover alloc] init];
[entryPopover setContentSize:NSMakeSize(200.0, 200.0)];
[entryPopover setBehavior:NSPopoverBehaviorTransient];
[entryPopover setAnimates:YES];
[entryPopover setContentViewController:viewController];
@jay
jay / PostJSON.c
Last active July 31, 2022 20:35
Use libcurl to POST JSON data.
/* Use libcurl to POST JSON data.
Usage: PostJSON <name> <value>
curl-library mailing list thread:
'how do i post json to a https ?'
https://curl.haxx.se/mail/lib-2015-01/0049.html
* Copyright (C) 2015 Jay Satiro <raysatiro@yahoo.com>
https://curl.haxx.se/docs/copyright.html
@myusuf3
myusuf3 / delete_git_submodule.md
Created November 3, 2014 17:36
How effectively delete a git submodule.

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run git rm --cached path_to_submodule (no trailing slash).
  • Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  • Commit git commit -m "Removed submodule "
  • Delete the now untracked submodule files rm -rf path_to_submodule

Description

When using Homebrew (http://brew.sh) and searching formulas or pull requests you may get the dreaded error message: Github API Rate limit exceeded

Let's fix that! (yeah!)


Short version

Create a new Personal Token in your Github Account Settings (Sidebar: Applications) and then copy the Token. In the Terminal, use export HOMEBREW_GITHUB_API_TOKEN=YOURAPITOKENWITHFUNKYNUMBERSHERE (change that to your API Token) or add that to your .bash_profile and then do source .bash_profile.