Skip to content

Instantly share code, notes, and snippets.

View hamsternik's full-sized avatar
:bowtie:
chasing on web x2

Nikita Khomitsevych hamsternik

:bowtie:
chasing on web x2
View GitHub Profile
@hamsternik
hamsternik / rofrest.R
Created August 15, 2014 10:54
r_forest_function
# any idea where i take the data :)
# but basically, i've taken it from 'data(...)'
rf_caret <- train(Class ~ ., data = train, method = "rf", trControl =
trainControl(method = "repeatedcv", repeats = 5))
rf_importance <- varImpPlot(rf_caret$finalModel)
@hamsternik
hamsternik / java_8_lambda
Created January 23, 2015 17:54
Using lambdas from Java 8 standart
List<String> names = Arrays.asList("nik", "andrey", "alena", "sasha");
// First method to sort Java "List" with strings
Collections.sort(names, new Comparator<String>() {
@Override
public int compareTo(String a, String b) {
return b.compareTo(a);
}
});
@hamsternik
hamsternik / gist:cdaf955d494f9000a45ed5293ea48ada
Created May 16, 2016 13:45
Bluetooth communication layer
- Implemented obtaining the list of available (paired) devices
- Implemented device connecting
- Implemented device disconnecting
@hamsternik
hamsternik / OpenWRT_install_KPI_guide.md
Last active September 22, 2016 22:02
OpenWRT_install_KPI_guide

Перепрошивка роутера TL-LINK на OpenWrt

Installation

Качаем c оф.сайта OpenWrt необходимую прошивку и необходимые для дальней работы пакеты, описание которых находится в глоссарии.

Заходим в веб-интерфейс по адрессу http://192.168.0.1. Как правило, для TP-LINK этот адресс именно такой.

В боковом меню находим пункт "Системные настройки" (как правило, над пунктом "Выход"). Там выбираем подпунтк "update firmware", выбираем на нашем диске необходимую прошивку, запускаем и ждем пока произойдет установка.

@hamsternik
hamsternik / UIStoryboard + Nib [initialization]
Last active January 24, 2019 19:55
Easy storyboard & nib initialization by the concrete class from the static method
class YourCustomViewController: UIViewController {
static func storyboardInstance() -> YourCustomViewController? {
// if your storyboard's name same as VC name
let storyboard = UIStoryboard(name: String(describing: self), bundle: nil)
// make concrete storyboard as initial to use this method
// else, use instantiateViewController(withIdentifier: _ )
return storyboard.instantiateInitialViewController() as? YourCustomViewController
}
}
- (BOOL)isConnectedToInternet
{
CFNetDiagnosticRef diag = CFNetDiagnosticCreateWithURL(kCFAllocatorDefault, (__bridge CFURLRef)[NSURL URLWithString:@"www.apple.com"]);
CFNetDiagnosticStatus status = CFNetDiagnosticCopyNetworkStatusPassively(diag, NULL);
CFRelease(diag);
if (status == kCFNetDiagnosticConnectionUp) {
return YES;
} else {
SomeModalViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"SomeModalViewControllerID"];
vc.providesPresentationContextTransitionStyle = YES;
vc.definesPresentationContext = YES;
vc.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
vc.modalPresentationStyle = UIModalPresentationOverCurrentContext; // UIModalPresentationPopover
[self presentViewController:vc animated:YES completion:nil];
@hamsternik
hamsternik / ModelFromUIModel.swift
Created March 19, 2017 23:14
Transform UIModel object to the Model using protocols
import Foundation
// MARK: Model
protocol ModelType {
init(value: Int)
}
class Model: ModelType {
var value: Int
@hamsternik
hamsternik / auth.cpp
Created March 28, 2017 18:30
Small project for the security information class
#include<iostream>
#include<fstream>
#include<sstream>
#include<streambuf>
#include<cstdlib>
#include<string>
#include<vector>
using std::string;