Skip to content

Instantly share code, notes, and snippets.

View ayarse's full-sized avatar

ayaz ayarse

View GitHub Profile
@ayarse
ayarse / init.lua
Last active December 10, 2020 00:55
My QCY bluetooth headphones keep connecting to my mbp in Slave mode for some reason macOS has issues playing audio when in slave mode. Once disconnected the device reconnects in Master mode. This Hammerspoon script watches audio device events and uses blueutil (toy/blueutil) to quickly disconnect and reconnect the device if its in slave mode.
hs.audiodevice.watcher.setCallback(function(evt)
if evt == "sOut" or evt == "dOut" then
hs.eventtap.keyStroke({}, 'F8')
end
qcyMac = "00-00-00-00-00-00"
devices = hs.execute("/usr/local/bin/blueutil --paired | grep -i qcy | grep -i slave");
if(string.len(devices) > 0) then
hs.execute("/usr/local/bin/blueutil --disconnect " .. qcyMac)
@ayarse
ayarse / laravel_post_receive hook
Created June 17, 2020 02:55 — forked from vool/laravel_post_receive hook
Post receive hook for Laravel website deploy
#!/bin/bash
echo "********************"
echo "Post receive hook: Updating website"
echo "********************"
#set the git repo dir
GIT_REPO_DIR=~/git/<repo>.git
echo "The git repo dir is $GIT_REPO_DIR"
@ayarse
ayarse / FVolumeKey.ahk
Created May 28, 2018 06:28
Control volume with Function keys AutoHotkey script
F2::
Send {Volume_Down}
Return
F3::
Send {Volume_Up}
Return
@ayarse
ayarse / live-blogging-plus.php
Last active February 19, 2018 09:12
Fixes bug on Wordpress Live Blogging (by cnorthwood) and Live Blogging Plus (vidyut) plugins where all posts are fetched when using the shortcode. Line 1166 has to be replaced with this snippet.
'tax_query' => array(
array(
'taxonomy' => 'liveblog',
'field' => 'name',
'terms' => $id,
),
),
var graph = require('fbgraph');
var access_token = '';
graph.setAccessToken(access_token);
getTheThing();
function getTheThing(url = "/me/posts/?fields=story,privacy") {
graph.get(url, function(err, res) {
var fs = require('fs');
fs.readFile('test.json', function(error, data) {
if (error) {
console.log(error);
return;
}
var obj = JSON.parse(data);
@ayarse
ayarse / copy_windows10_lockscreen_backgrounds_to_desktop.js
Created July 26, 2016 15:14
I use this to copy windows 10 lockscreen background images to a folder in the desktop. can be used to set one of those as your wallpaper.
var fso = new ActiveXObject("Scripting.FileSystemObject");
var wshshell = new ActiveXObject("wscript.shell");
var localAppData = wshshell.ExpandEnvironmentStrings("%localappdata%");
var userProfile = wshshell.ExpandEnvironmentStrings("%USERPROFILE%");
var lsbCacheLocation = localAppData + "\\Packages\\Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy\\LocalState\\Assets"; // might need to be changed
var lsbDesktop = userProfile + "\\Desktop\\lsbCache";
var a = fso.CopyFolder(lsbCacheLocation, lsbDesktop);
var allFiles = fso.GetFolder(lsbDesktop);
var nfName = 0;
for (var index = new Enumerator(allFiles.Files); !index.atEnd(); index.moveNext()) {
@ayarse
ayarse / convert_aria_to_innodb.sh
Created June 20, 2016 00:15
A little script I use to import mariadb database dumps to mysql without errors
#!/bin/bash
echo -n "INPUT FILENAME > "
read fINPUT
echo -n "OUTPUT FILENAME > "
read fOUTPUT
sed -e 's/ENGINE=Aria/ENGINE=InnoDB/' -e 's/PAGE_CHECKSUM=1//' -e 's/TRANSACTIONAL=1//' $fINPUT > $fOUTPUT;
read -p "Press any key to exit..."
@ayarse
ayarse / generate_otf_previews.sh
Created May 28, 2016 05:59
Generates PNG previews for OTF files and appends them all into one file using imagemagick
#!/usr/bin/bash
i=1;
IFS=$'\n';
for f in `find . -name "*.otf" -type f | grep -i regular | grep -v -i macosx`; do
convert -size x100 -gravity center -font "$f" -pointsize 16 label:"${f##*/}: some text" font_$((i++)).png;
done;
convert -append font_*.png fonts.png
@ayarse
ayarse / .equalize-by-first.js
Created May 26, 2015 20:44
Give the height of first div to all consecutive divs in an element that has class .equalize-by-first
$(window).load( function() {
$('.equalize-by-first > div').height(function() {
if( $(this).index() !== 0 ) {
var zHeight = $('.equalize-by-first > div:first-child').outerHeight();
return zHeight;
}
});
});