Skip to content

Instantly share code, notes, and snippets.

@atika
atika / README.md
Last active Aug 1, 2022
Text field and options dropdown for espanso (macOS only)
View README.md

Simple prompt for espanso https://espanso.org/ on macOS

For the time being, espanso does not come with a graphical user interface, in the meanwhile you can use this workaround to prompt for text or select result in a list, on macOS.

Create a folder scripts in the espanso preferences folder and copy these files: /Users/<username>/Preferences/espanso/scripts/.

You can also copy Pashua app app into this folder.

espanso popup demo

@atika
atika / network_drive.list
Created Mar 26, 2017
Generate macOS apps from a list to mount your networks volumes
View network_drive.list
Awesome Volume;afp://macbookpro.local/MyHD
Home on MacBookPro;afp://macbookpro.local/macuser
DiskStation Video;smb://192.168.0.20/video
DiskStation Music;smb://192.168.0.20/music
@atika
atika / marked-markdown-preprocessor.rb
Last active Sep 29, 2018
Use Marked 2 markdown preprocessor functionality to rewrite each image URL to an absolute path on the system before displaying the preview.
View marked-markdown-preprocessor.rb
#!/usr/bin/ruby
require 'pathname'
imgURLRegex = /^(!\[.*?\]\()([^\s\)]*)(\s*.*\))/
rootsPaths = [
'/Users/username/Path/To/hexo/source/',
'/Another/PathTo/Website/Directory/'
]
@atika
atika / CodeRunner-AngularJS-Exemple.js
Created Mar 10, 2016
CodeRunner compilation script to have Javascript, HTML and CSS in the same file
View CodeRunner-AngularJS-Exemple.js
// The first script tag is optional if you start with javascript
//<script>
$(document).ready(function () {
$("body").append("<br>jQuery said AngularJS rocks!");
alert($(document).html());
});
angular.module('PricesApp', [])
.controller("PriceController", function () {
@atika
atika / RemapValueToAnotherRange.swift
Created Mar 10, 2016
Remap/Convert a value from one range to another range (graph) in Swift
View RemapValueToAnotherRange.swift
let high1 = 1000
let low1 = 200
let high2 = 250
let low2 = 10
let value = 200
let remapedValue = low2 + (value - low1) * (high2 - low2) / (high1 - low1)
@atika
atika / NSTimeZoneTest.swift
Created Mar 10, 2016
NSTimeZone tests and change app default TimeZone in Swift
View NSTimeZoneTest.swift
let tz = NSTimeZone.init(forSecondsFromGMT:3600)
NSTimeZone.setDefaultTimeZone(tz) // Change app default timezone
print(tz) // GMT+0100 (UTC+1) offset 3600
print(NSDate()) // 2016-03-10 09:57:44 +0000
print(tz.abbreviation) // Optional("UTC+1")
print(tz.name) // GMT+0100
print(tz.description) // GMT+0100 (UTC+1) offset 3600
@atika
atika / SecondsToDaysHoursMinutesSeconds.swift
Created Mar 10, 2016
Convert seconds to days, hours, minutes, seconds in Swift
View SecondsToDaysHoursMinutesSeconds.swift
let seconds = 86400*4 + 3600*2 + 65
print(String((seconds / 86400)) + " days")
print(String((seconds % 86400) / 3600) + " hours")
print(String((seconds % 3600) / 60) + " minutes")
print(String((seconds % 3600) % 60) + " seconds")
@atika
atika / FloatToDecimalStringExtension.swift
Last active Mar 10, 2016
Format a float value with desired numbers after the comma to a string. Doesn't display the comma if the number is a round value.
View FloatToDecimalStringExtension.swift
// Format a float value with desired numbers after the comma to a string. Doesn't display the comma if the number is a round value.
import Foundation
extension Double {
func toDecimalString(decimals: Int = 0) -> String {
let format = (self % 1 > 0 && decimals > 0) ? "%.\(decimals)f" : "%.0f"
return String(format:format, self)
}
@atika
atika / generate_nginx_vhosts_puphpet.php
Last active Jan 15, 2016
Generate Vagrant/PuPHPet Nginx vhosts configuration for multiples sites
View generate_nginx_vhosts_puphpet.php
<?php
$websites = [
["uid" => "mywebsite01", "name" => "mywebsite01.dev", "alias"=>"www.mywebsite01.dev", "root" => "/var/www/mywebsite01/www"],
["uid" => "mywebsite02", "name" => "mywebsite02.dev", "alias"=>"", "root" => "/var/www/mywebsite02/www"]
];
$template =
" nxv__UID_:
@atika
atika / alias_stats.txt
Last active Apr 9, 2016
Statistics of shell aliases usage and optional search for a specific command (change to .bash_history for Bash Shell)
View alias_stats.txt
alias_stats() {
local search="$1"
list=""; for c in $(alias | grep "$search" | cut -d'=' -f1); do count=$(grep -Ec ";$c" ~/.zsh_history); list="${list}\n${count} ${c}"; done; echo -e $list | sort -n | grep -Ev "^0"
}