Skip to content

Instantly share code, notes, and snippets.

@atika
atika / README.md
Last active September 25, 2023 19:01
Text field and options dropdown for espanso (macOS only)

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 March 26, 2017 15:50
Generate macOS apps from a list to mount your networks volumes
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 September 29, 2018 03:40
Use Marked 2 markdown preprocessor functionality to rewrite each image URL to an absolute path on the system before displaying the preview.
#!/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 March 10, 2016 10:58
CodeRunner compilation script to have Javascript, HTML and CSS in the same file
// 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 March 10, 2016 10:10
Remap/Convert a value from one range to another range (graph) in 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 March 10, 2016 09:59
NSTimeZone tests and change app default TimeZone in 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 March 10, 2016 09:55
Convert seconds to days, hours, minutes, seconds in 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 March 10, 2016 09:50
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.
// 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 January 15, 2016 12:36
Generate Vagrant/PuPHPet Nginx vhosts configuration for multiples sites
<?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 April 9, 2016 14:56
Statistics of shell aliases usage and optional search for a specific command (change to .bash_history for Bash Shell)
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"
}