Skip to content

Instantly share code, notes, and snippets.

View GendelfLugansk's full-sized avatar

Gennady Dogaev GendelfLugansk

View GitHub Profile
@GendelfLugansk
GendelfLugansk / launcher.au3
Last active June 27, 2021 01:31
Origin 1.3.6 Launcher
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Compression=0
#AutoIt3Wrapper_Res_HiDpi=Y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <File.au3>
;Function for getting HWND from PID
Func _GetHwndFromPID($PID, $title)
$hwnd = 0
@GendelfLugansk
GendelfLugansk / README.md
Last active February 24, 2024 19:45
Wrapper for expo-sqlite with async/await, migrations and transactions

Expo-sqlite - the right way

Why

With expo-sqlite it's not possible to execute few depending statements inside single transaction - db.transaction does not work with async/promise and tx.executeSql just enqueues sql statement but does not execute it.

Documentation

Database class has two methods - execute (to execute single statement without transaction) and transaction(cb) to execute few statements inside a transaction

@GendelfLugansk
GendelfLugansk / controllers.application.js
Last active January 3, 2020 18:51
Question 59529650
import Ember from 'ember';
import EmberObject, { set } from '@ember/object';
import ArrayProxy from '@ember/array/proxy';
import { Promise, resolve, all } from 'rsvp';
const section = EmberObject.create();
const log = ArrayProxy.create({ content: [] });
export default Ember.Controller.extend({
appName: 'Question 59529650',
@GendelfLugansk
GendelfLugansk / README.md
Created August 3, 2019 18:48
Dynamically change tawk locale

If you need to change tawk's locale dynamically (i.e. in SPA), here is the code I use. There is a small issue, though - everytime tawk adds new div to body and there is no way to correctly detect it and remove (ids are dynamic and there is no classname). However, as far as it is hidden, this should not be a problem.

@GendelfLugansk
GendelfLugansk / README.md
Created July 22, 2019 12:26
JavaScript: decodeURIComponentWin1251

This method decodes string that was encoded by PHP's urlencode method using windows-1251 encoding (i.e. php -r "echo urlencode(iconv('utf8', 'windows-1251', 'Что-то с чем-то'));")

@GendelfLugansk
GendelfLugansk / awaitable-timeout.js
Created February 26, 2019 23:44
Simple function to retry requests using request-promise module
export default function(t) {
return new Promise(resolve => {
setTimeout(resolve, t);
});
}
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
import Ember from 'ember';
export default Ember.Component.extend({
line1: "Say Hi!",
line2: "Say Yeah!",
changeAction(newAction) {
switch (newAction) {
case "1":
@GendelfLugansk
GendelfLugansk / gac.js
Last active April 28, 2018 20:47
Google analytics integration with user notice and consent (for static website which uses GA)
/**
* Put this code in <head> tag. 'UA-XXXXX-Y' should be replaced with the property ID (also called the "tracking ID")
* of the Google Analytics property you wish to track. Also you may wish to change text and remove
* `ga('set', 'anonymizeIp', true);` line from `initGac` function. Style user notice with css.
*
* Please note that when user clicks "Disable cookies" this script removes google analytics' cookies and adds
* cookie with name `_gac_consent_`. It doesn't store any user data, just 'allow' or 'disable' string. This is
* needed to store user's answer. You may want to inform users about that in your Cookie Policy.
*/
import Ember from 'ember';
export default Ember.Component.extend({
classNames: ["person-card"]
});