Skip to content

Instantly share code, notes, and snippets.

View ripesunflower's full-sized avatar
😴

ripesunflower ripesunflower

😴
  • Russia, Saint-Petersburg
View GitHub Profile
@ripesunflower
ripesunflower / find_gcd.rb
Created December 21, 2015 21:13
Binary euclidean recursive algorithm for gcd
def find_gcd(a, b)
if a == 0; b
elsif b == 0; a
elsif a == b; a
elsif a == 1 || b == 1; 1
elsif a.even? && b.even?; 2 * find_gcd(a / 2, b / 2)
elsif a.even? && b.odd?; find_gcd(a / 2, b)
elsif a.odd? && b.even?; find_gcd(a, b / 2)
elsif a.odd? && b.odd?; (b > a) ? find_gcd((b - a) / 2, a) : find_gcd((a - b) / 2, b)
end
@ripesunflower
ripesunflower / unlimited_life.js
Last active January 4, 2016 01:26
Unlimited Conway's Life | Codewars
let ArrayUtils = {}
ArrayUtils.getSquare = function(x, y) {
return Array.apply(null, Array(y)).map( () => Array.apply(null,
Array(x)).map(() => 0) );
};
ArrayUtils.crop = function(array) {
let top, bottom, left, right;
@ripesunflower
ripesunflower / calculating_with_functions.rb
Last active January 20, 2016 19:30
Calculating with Functions | Codewars
[:zero, :one, :two, :three, :four, :five,
:six, :seven, :eight, :nine].each.with_index do |method, index|
define_method method do |function = nil|
(function) ? function.call(index) : index
end
end
[[:plus, :+], [:minus, :-],
[:times, :*], [:divided_by, :/]].each do |(method, action)|
define_method method do |second_operand|
@ripesunflower
ripesunflower / tap.md
Created September 15, 2017 06:14
The Task-based Asynchronous Pattern
// in addUploadFeature.js
/**
* Convert a `File` object returned by the upload input into a base 64 string.
* That's not the most optimized way to store images in production, but it's
* enough to illustrate the idea of data provider decoration.
*/
const convertFileToBase64 = (file: any) => new Promise((resolve, reject) => {
const reader = new FileReader();
reader.readAsDataURL(file.rawFile);
public interface ICatalogue
{
int Id { get; set; }
string Name { get; set; }
}
public abstract class BaseEnumController<TEnum, TViewModel> : Controller
where TEnum : struct, IConvertible, IFormattable
where TViewModel : class, ICatalogue, new()
{
@ripesunflower
ripesunflower / trash_remove_from_phone_2021.md
Last active January 2, 2022 06:41
Удаление установленых по дефолту приложений на телефоны Samsung согласно требованиям РФ (Госуслуги, VK, Mailru и прочее)

Подготовка

  1. Включить режим разработчика на телефоне (обычно это 7 раз тапнуть на номер билда в разделе о системе)
  2. В настройках для разработчиков включить пункт "Отладка по USB"
  3. На компьютере скачать Android SDK Platform-Tools и найти директорию с adb
  4. Подключить телефон по USB к компьютеру
  5. В командной строке запустить adb devices, эта команда выведет список подключенных устройств, а на телефоне появится диалоговое окно с разрешением, где надо нажать Ok. Сначала напротив имени устройства будет unknown, после разрешения на телефоне и очередного запуска команды adb devices напротив имени устройства будет device
  6. Теперь можно запустить adb shell

Полезности