Skip to content

Instantly share code, notes, and snippets.

View ayarse's full-sized avatar

ayaz ayarse

View GitHub Profile
@ayarse
ayarse / Capture.php
Last active August 29, 2015 14:21
Function that forces functions to return instead of echoing output
<?php
function capture($callback)
{
$args = func_get_args();
array_shift($args);
ob_start();
if (count($args))
call_user_func_array($callback, $args);
else
call_user_func($callback);
@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;
}
});
});
@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 / 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 / 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()) {
var fs = require('fs');
fs.readFile('test.json', function(error, data) {
if (error) {
console.log(error);
return;
}
var obj = JSON.parse(data);
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) {
@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,
),
),
@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 / 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"