Skip to content

Instantly share code, notes, and snippets.

View falkolab's full-sized avatar
🏠
Working from home

Andrey Tkachenko falkolab

🏠
Working from home
  • Russian Federation
View GitHub Profile
@falkolab
falkolab / download.js
Created July 30, 2014 08:16
Download file by http with progress (NodeJS)
function download(fileUrl, apiPath, callback) {
var url = require('url'),
http = require('http'),
p = url.parse(fileUrl),
timeout = 10000;
var file = fs.createWriteStream(apiPath);
var timeout_wrapper = function( req ) {
return function() {
@falkolab
falkolab / gist:17d5af280ef09e98856c5e998713625f
Last active October 11, 2023 12:46
New act runner run in docker lead to error 500 on server
Runner logs:
time="2023-10-11T08:48:01Z" level=info msg="Starting runner daemon"
time="2023-10-11T08:48:01Z" level=warning msg="Because the Gitea instance is an old version, skip declare labels and version."
time="2023-10-11T08:48:01Z" level=error msg="failed to fetch task" error="unknown: rpc error: code = Unauthenticated desc = unregistered runner"
...
Server logs:
@falkolab
falkolab / Dockerfile
Last active October 23, 2022 17:35
Docker. Install TA-lib alpine wheel multistage build
FROM python:3-alpine as talib_build
# TA-Lib
RUN apk add --virtual .build-deps musl-dev build-base && \
wget http://prdownloads.sourceforge.net/ta-lib/ta-lib-0.4.0-src.tar.gz && tar -xvzf ta-lib-0.4.0-src.tar.gz && \
cd ta-lib/ && ./configure --prefix=/talib_dist && make && make install && \
python3 -m pip wheel --wheel-dir=/wheels TA-Lib==0.4.24 && \
apk del .build-deps && cd .. && rm -rf ./ta-lib && rm -rf ./ta-lib-0.4.0-src.tar.gz
FROM python:3-alpine
@falkolab
falkolab / index.js
Created October 29, 2015 11:45
How to use SVG as View backgroundImage
$.getView().backgroundImage = getImageFileFromSVG({
image : "/images/hearts.svg",
width : 400,
height : 400,
top : 0,
left : 0
});
function getImageFileFromSVG(svgOpts) {
var file = Ti.Filesystem.getFile(Ti.Filesystem.applicationCacheDirectory,
@falkolab
falkolab / SVGProduct.js
Created October 30, 2015 11:47
How to use SVG as autogenerated raster image
// app/lib/SVGProduct.js
function getImageFileFromSVG(svgOpts, name) {
var file = Ti.Filesystem.getFile(Ti.Filesystem.applicationCacheDirectory,
Ti.Utils.md5HexDigest(JSON.stringify(svgOpts)));
if (!file.exists()) {
var SVG = require('com.geraudbourdin.svgview');
if (!file.write(SVG.createView(svgOpts).toImage())) {
Ti.API.error("Can't save to file. Product:", name);
return null;
@falkolab
falkolab / TelephonyInfoProxy.java
Last active September 11, 2017 12:16
Titanium android module proxy to check whether the phone is dual SIM
// http://stackoverflow.com/a/17499889/506724
package com.falkolab.drunkmode.platform;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Method;
import java.util.ArrayList;
import org.appcelerator.kroll.KrollProxy;
@falkolab
falkolab / README.md
Last active July 18, 2017 22:35
How to use latest Alloy with appc CLI

If you want to use latest alloy with appc CLI command:

  1. Update Alloy: [sudo] npm install -g alloy

  2. Create file in your project <project root>/plugins/global.alloy/1.0/hooks/global_alloy_hook.js with content:

exports.init = function (logger, config, cli, appc) {
	delete process.env.ALLOY_PATH;
};
@falkolab
falkolab / callLog.js
Created November 27, 2015 08:49
list view databinding helper
exports.populateCallLog = function(listview, items) {
var helper = require('listViewHelper');
return helper.populate(listview, items, false /*no merge*/, function sectionGenerator(lv, items) {
var moment = require("alloy/moment");
var headerViewCtrl = Alloy.createController('modules/call/log/pickerSectionHeaderView');
var dateTitle,
item = items[0],
utcTime = new Date(),
@falkolab
falkolab / resizeToContainer.js
Created January 28, 2016 14:57
Titanium SDK helper to resize
function resizePhoto(blob, size) {
var measurement = require('alloy/measurement'), w, h;
if (blob.width / blob.height >= size.width / size.height) {
w = measurement.dpToPX(size.width);
h = blob.height * measurement.dpToPX(size.width) / blob.width;
} else {
w = blob.width * measurement.dpToPX(size.height) / blob.height;
h = measurement.dpToPX(size.height);
@falkolab
falkolab / alloy.js
Last active March 14, 2017 22:51
Application launch manager for Titanium SDK
require('runner').on('run', function(evt) {
// evt.source - runner module reference
var hc = Alloy.CFG.homeController;
// home window launch
Alloy.createController(hc.name, hc.args).getView().open();
});