Skip to content

Instantly share code, notes, and snippets.

View Lerg's full-sized avatar

Sergey Lerg Lerg

View GitHub Profile
@Lerg
Lerg / prepare_icons.sh
Last active April 11, 2024 19:25
Make all app icons with imagemagick, iOS and Android
#!/bin/sh
base=$1
convert "$base" -resize '29x29' -unsharp 1x4 "Icon-Small.png"
convert "$base" -resize '40x40' -unsharp 1x4 "Icon-Small-40.png"
convert "$base" -resize '50x50' -unsharp 1x4 "Icon-Small-50.png"
convert "$base" -resize '57x57' -unsharp 1x4 "Icon.png"
convert "$base" -resize '58x58' -unsharp 1x4 "Icon-Small@2x.png"
convert "$base" -resize '60x60' -unsharp 1x4 "Icon-60.png"
convert "$base" -resize '72x72' -unsharp 1x4 "Icon-72.png"
convert "$base" -resize '76x76' -unsharp 1x4 "Icon-76.png"
@Lerg
Lerg / LambdaTimer.cs
Created February 2, 2024 12:52
Timer with a lambda function execution on timeout for Godot 3
using Godot;
using System;
/*
var timer = new LambdaTimer(() => GD.Print("hello timer!"));
AddChild(timer);
*/
public class LambdaTimer : Timer {
private Action onTimeOutAction { get; }
@Lerg
Lerg / colors.lua
Created July 1, 2014 07:22
147 color names as a Lua table, RGB from 0 to 1.
return {
aliceblue = {0.94117647058824, 0.97254901960784, 1},
antiquewhite = {0.98039215686275, 0.92156862745098, 0.84313725490196},
aqua = {0, 1, 1},
aquamarine = {0.49803921568627, 1, 0.83137254901961},
azure = {0.94117647058824, 1, 1},
beige = {0.96078431372549, 0.96078431372549, 0.86274509803922},
bisque = {1, 0.89411764705882, 0.76862745098039},
black = {0, 0, 0},
blanchedalmond = {1, 0.92156862745098, 0.80392156862745},
@Lerg
Lerg / tasks.json
Last active July 7, 2023 22:29
"Jai: Build & Run" - VS Code task for building and running a Jai program
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "Jai: Build & Run",
"command": "jai -quiet ${file} && ${fileDirname}${pathSeparator}${fileBasenameNoExtension}",
"group": "build",
"presentation": {
"revealProblems": "onProblem",
@Lerg
Lerg / random_desktop_image.scpt
Last active February 5, 2023 20:57
macOS AppleScript to set the same random picture as a desktop background on all monitors. Pictures are taken from the `~\Pictures` directory.
tell application "Finder"
set randomimage to some file of folder ((path to home folder as string) & "Pictures") as string
end tell
tell application "System Events"
tell every desktop
set random order to false
set picture to randomimage
end tell
end tell
@Lerg
Lerg / n28s.lua
Last active December 2, 2022 16:43
Script wrapper for Defold
local hashed = require('libs.hashed')
local _M = {}
local scripts = {}
-- NoMoreGlobalFunctionsInScripts
function _M.new()
local script = {
@Lerg
Lerg / main.lua
Last active November 6, 2022 21:04
Take screenshots in simulator with S key
if app.isSimulator then
Runtime:addEventListener('key', function (event)
if event.keyName == 's' and event.phase == 'down' then
local scene = storyboard.getScene(storyboard.getCurrentSceneName())
if scene and scene.view then
display.save(scene.view, display.pixelWidth .. 'x' .. display.pixelHeight .. '_' .. math.floor(system.getTimer()) .. '.png')
return true
end
end
end)
@Lerg
Lerg / utils.lua
Last active August 23, 2022 20:09
local mRandom = math.random
local tInsert = table.insert
local app = require('lib.app')
-------------------------------------------
-- Shuffle a table
-------------------------------------------
table.shuffle = function (t)
local n = #t
while n > 2 do
-- n is now the last pertinent index
@Lerg
Lerg / index-content.js
Last active September 3, 2021 08:18
Manual preview cut for {{content}} helper in Ghost platform
// ### Content Helper
//
// *Usage example:*
// `{{content}}`
// `{{content words="20"}}`
// `{{content characters="256"}}`
// `{{content preview="true"}}`
//
// Turns content html into a safestring so that the user doesn't have to
// escape it or tell handlebars to leave it alone with a triple-brace.
--[[
A simple sample game for Corona SDK.
http://coronalabs.com
Made by @SergeyLerg.
Licence: MIT.
]]
-- Don't show pesky status bar.
display.setStatusBar(display.HiddenStatusBar)