Skip to content

Instantly share code, notes, and snippets.

View inoyakaigor's full-sized avatar
😎
😎

Igor «InoY» Zviagintsev inoyakaigor

😎
😎
View GitHub Profile
@antixrist
antixrist / gist:faf300eb04c1aeca9137
Created August 10, 2014 09:10
VK API: Parse json Args to array.
/**
* For check: https://vk.com/dev/execute
*/
// var myList = Args.list;
// var listSeparator = Args.listSeparator;
// var listItemsType = Args.listItemsType;
var myList = "123456,789012,345678,901234,567890";
@odewahn
odewahn / error-handling-with-fetch.md
Last active June 9, 2024 14:27
Processing errors with Fetch API

I really liked @tjvantoll article Handling Failed HTTP Responses With fetch(). The one thing I found annoying with it, though, is that response.statusText always returns the generic error message associated with the error code. Most APIs, however, will generally return some kind of useful, more human friendly message in the body.

Here's a modification that will capture this message. The key is that rather than throwing an error, you just throw the response and then process it in the catch block to extract the message in the body:

fetch("/api/foo")
  .then( response => {
    if (!response.ok) { throw response }
    return response.json()  //we only get here if there is no error
 })
@vsaarinen
vsaarinen / react-some-component.d.ts
Last active April 25, 2020 22:42
How to add TypeScript prop type definitions to an existing React component
import * as React from 'react';
declare class SomeReactComponent extends React.Component<SomeReactComponentProps, any> {}
interface SomeReactComponentProps {
className?: string;
toggle?: boolean;
name: string;
size?: 'lg' | '2x' | '3x' | '4x' | '5x';
}
@wavezhang
wavezhang / java_download.sh
Last active July 19, 2024 13:45
download java from oracle without login
wget -c --no-cookies --no-check-certificate --header "Cookie: oraclelicense=accept-securebackup-cookie" https://download.oracle.com/otn-pub/java/jdk/12.0.2+10/e482c34c86bd4bf8b56c0b35558996b9/jdk-12.0.2_linux-x64_bin.tar.gz
@mweststrate
mweststrate / mobx-webcomponent.html
Last active January 22, 2024 08:25
MobX + webcomponents
<!DOCTYPE html>
<html>
<head>
<script src="https://unpkg.com/mobx@2.6.0/lib/mobx.umd.js"></script>
<script>
var MobxDemo = Object.create(HTMLElement.prototype);
MobxDemo.attachedCallback = function() {
var state = mobx.observable({
counter : parseInt(this.getAttribute("counter"))
})
@PofMagicfingers
PofMagicfingers / apkdebug.sh
Created July 21, 2017 14:58
Enable debugging flag on an APK using apktool. Can be useful to debug cordova, etc on already compiled apps
#!/bin/sh
command -v apktool >/dev/null 2>&1 || { echo >&2 "I require apktool but it's not installed. Aborting."; exit 1; }
command -v keytool >/dev/null 2>&1 || { echo >&2 "I require keytool but it's not installed. Aborting."; exit 1; }
command -v jarsigner >/dev/null 2>&1 || { echo >&2 "I require jarsigner but it's not installed. Aborting."; exit 1; }
TMPDIR=`mktemp -d 2>/dev/null || mktemp -d -t 'apkdebug'`
APK=$1
DEBUG_APK="${APK%.*}.debug.apk"
if [ -f $APK ]; then
@dominikwilkowski
dominikwilkowski / README.md
Created September 5, 2020 02:57
ANSI codes for cli controled output

ANSI escape codes

ANSI escape codes can be printed to a shell to as instructions. The below is a list of codes I have used often in my CLI programs and I find myself looking up over and over again.

A great article about it can be found here.

Content

@sindresorhus
sindresorhus / esm-package.md
Last active July 23, 2024 10:30
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.

Гайд заполнения анкеты на загранпаспорт РФ 10 лет (биометрический) в Ереване/Гюмри в 2022 году

При помощи этих подсказок уже осуществлялись подачи на загранпаспорт в Гюмри и Ереване - все прошло успешно, работники консульства не задавали никаких вопросов.

Для подачи на загран алгоритм такой:

  • Ловим слот и записываемся в Ереван/Гюмри. Слоты появляются в начале каждого месяца (примерно 31-1ое число) для записи на следующий (в Гюмри более случайно, бывает и в середине месяца). Кроме того иногда люди отказываются от своих записей и они тоже становятся доступны.
  • За 2 рабочих дня звоним в консульство (после записи в слот придет письмо с телефоном) и подтверждаем визит.