Skip to content

Instantly share code, notes, and snippets.

@ZevEisenberg
ZevEisenberg / resetAllSimulators.sh
Last active November 30, 2022 09:27
Reset all iOS simulators with this one weird trick
osascript -e 'tell application "iOS Simulator" to quit'
osascript -e 'tell application "Simulator" to quit'
xcrun simctl erase all
@cpeppas
cpeppas / gist:b5ffe6bd29b67d96416a
Last active September 1, 2017 17:13
Espresso CustomMatcher to help test things like Actionbar title
import android.view.View;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeMatcher;
import static org.hamcrest.Matchers.is;
public class CustomMatchers {
public static Matcher<View> withResourceName(String resourceName) {
@intari
intari / rescuetime_hg_commit_hook
Created May 25, 2015 05:06
Commit hook to log commit messages as highlights to RescueTime
#!/bin/sh
#
# Log commit messages as a 'highlight' in RescueTime Premium for Mercurial
#
# To enable this hook:
#
# 1. Get your API key from https://www.rescuetime.com/integrations/git
# 2. Place this file somewhere
# 3. Make sure it has executable permissions (chmod +x post-commit)
# 4. add line commit=path/to/this to [hooks] session of your .hgrc
@intari
intari / DrawerItemWithBadgeInCircle.java
Created June 11, 2015 06:16
Make it possible to use custom centered background resource in MaterialDrawer library
package com.viorsan.gists.example1
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

Computer science theory

  1. Что такое инвариант цикла?

  2. Что такое сложность алгоритма? O(n) нотация. O(???) для операций с NSArray, NSDictionary, запрос в БД (индексированный VS. неиндексированный)

  3. CS data structures (linked list, binary tree, array)

  4. Различия аутентификации, авторизации

@kalloc
kalloc / patriot.sh
Last active December 5, 2017 21:36
#!/bin/bash
wget -q -O /tmp/ips http://reestr.rublacklist.net/api/ips || exit 404
HASH=$(md5sum /tmp/ips | awk '{print $1}')
HASH_LAST=$(cat /tmp/ips.hash)
if [[ $HASH == $HASH_LAST ]] && [[ $(ip ro list dev tun2) != "" ]];then
exit 304
fi
IPS=$(cat /tmp/ips | sed 's|;|\n|g' | /bin/grep -E ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$; cat /root/addition_ips)
for rule in $(ip ro list dev tun2 | awk '{print $1}');do
@alashow
alashow / OkHttp3Stack.java
Last active May 21, 2024 01:54 — forked from bryanstern/OkHttpStack.java
An OkHttp backed HttpStack for Volley (okhttp3 version)
/**
* The MIT License (MIT)
*
* Copyright (c) 2015 Circle Internet Financial
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@ripper
ripper / sshd_tunnel.sh
Last active June 27, 2023 16:09
A script to launch user sshd limited to creation of reverse tunnels
#!/bin/sh
AUTHORIZED_KEYS=authorized_keys
HOST_RSA_KEY=ssh_host_rsa_key
SSHD=/usr/sbin/sshd
PORT=8443
case "$AUTHORIZED_KEYS" in /*) ;; *) AUTHORIZED_KEYS=$PWD/$AUTHORIZED_KEYS ;; esac
case "$HOST_RSA_KEY" in /*) ;; *) HOST_RSA_KEY=$PWD/$HOST_RSA_KEY ;; esac
@palaniraja
palaniraja / timezone.txt
Created March 20, 2016 20:04
osx list of timezone - output of command "sudo systemsetup -listtimezones"
Africa/Abidjan
Africa/Accra
Africa/Addis_Ababa
Africa/Algiers
Africa/Asmara
Africa/Bamako
Africa/Bangui
Africa/Banjul
Africa/Bissau
Africa/Blantyre
@SmartFinn
SmartFinn / dhcp-leases-to-dns.rsc
Last active April 30, 2024 12:57
MikroTik (RouterOS) script for automatically setting DNS records for clients when they obtain a DHCP lease
# MikroTik (RouterOS) script for automatically setting DNS records
# for clients when they obtain a DHCP lease.
#
# author SmartFinn <https://gist.github.com/SmartFinn>
:local dnsTTL "00:15:00";
:local token "$leaseServerName-$leaseActMAC";
# Normalize hostname (e.g. "-= My Phone =-" -> "My-Phone")
# - truncate length to 63 chars