Skip to content

Instantly share code, notes, and snippets.

@321zeno
321zeno / clockify.js
Created October 8, 2020 17:43
Clockify Helper
async function clockifyRequest(endpoint, token, method = 'GET', body) {
const fetchParams = {
headers: {
'X-Api-Key': token,
'Accept': 'application/json',
'Content-Type': 'application/json'
},
method: method,
}
if (!!body) {
@321zeno
321zeno / .bashrc
Last active November 27, 2019 10:18
.bashrc
# Formatting json
alias jq=/d/Tools/jq-win64.exe
# Enable highlighting in grep
alias grep='grep --color=auto'
# Better file listing
alias ll='ls -lhFA --color --group-directories-first'
# alias ports='netstat -tulanp'
alias ..="cd .."
# Search processes table ex: psg bash, psg apache2
alias psg="ps aux | grep -v grep | grep -i -e VSZ -e"
@321zeno
321zeno / debug_laravel_query.php
Created February 27, 2017 11:16
Debugging a Laravel query
<?php
// $query would be a query builder object
$bindings = $query->getBindings();
foreach ($bindings as $i => $binding) {
if ($binding instanceof \DateTime) {
$bindings[$i] = $binding->format('\'Y-m-d H:i:s\'');
} elseif (is_string($binding)) {
$bindings[$i] = "'$binding'";
}
@321zeno
321zeno / gulpfile.js
Created July 20, 2016 16:02
Tabs to spaces using globally installed node modules
// USAGE:
// Assuming you have gulp installed globally
// npm install -g gulp-soften yargs gulp-eol gulp-trimlines path-exists
// gulp --folder public_html OR gulp --folder public_html/styles
var base = process.env.USERPROFILE + '/AppData/Roaming/',
node_modules = base + 'npm/node_modules/';
var gulp = require(node_modules + 'gulp');
@321zeno
321zeno / tinymce.charcount.js
Last active October 26, 2023 03:55
Character counter plugin for TinyMCE 4
tinymce.PluginManager.add('charcount', function(editor) {
editor.on('init', function() {
function getCharacterLength() {
var text = editor.getContent({format: 'text'});
// trim and transform newlines ("\n" has a length of 2) to spaces (length = 1)
text = text.trim().replace(/(\n)+/g, " ");
return text.length;
}
@321zeno
321zeno / remove_hover_rule.js
Last active September 10, 2015 09:19 — forked from rcmachado/remove_hover_rule.js
Remove CSS :hover rules for touch devices to avoid iOS double-tap behavior. Copied and adapted from http://retrogamecrunch.com/tmp/hover (just a fix for sheet.cssRules)
// disable :hover on touch devices
// based on https://gist.github.com/4404503
// via https://twitter.com/javan/status/284873379062890496
// + https://twitter.com/pennig/status/285790598642946048
// re http://retrogamecrunch.com/tmp/hover
// NOTE: we should use .no-touch class on CSS
// instead of relying on this JS code
function removeHoverCSSRule() {
if ('createTouch' in document) {
try {
@321zeno
321zeno / ImageResizeController.php
Last active August 29, 2015 14:22
Resize images on the fly
<?php
class ImageResizeController extends BaseController {
/**
* This method catches urls like /imagecache/width/height/path/to/original_image.jpg and
* creates the image if public/imagecache/width/height/path/to/original_image.jpg doesn't exist.
*
* Urls like this are used for returning a resized version of /path/to/original_image.jpg
@321zeno
321zeno / DropzoneController.php
Created May 24, 2015 16:36
Replace a file input with a dropzone (for an image) in Laravel 4.x
<?php
class DropzoneController extends BaseController {
public function upload() {
$r = Util::uploadUnique('file', Config::get('website.dropzone_uploads'));
extract($r);
//return response
@321zeno
321zeno / AdminRedactorController.php
Last active August 29, 2015 14:21
Using Redactor WYSIWYG with Laravel 4.x
<?php
class AdminRedactorController extends AdminController {
private $publicFolder = 'redactor_uploads';
private $uploadFolder = 'public/' . $publicFolder;
public function fileUpload(){
@321zeno
321zeno / mustache-object-php.php
Last active December 17, 2015 08:49
A simple class to initialize objects to use with Mustache.php
<?php
class Core_Base
{
/**
* the constructor will assign
* - the values specified in the constructor's arguments, in that specific order as the object's properties
* - if an array is passed as argument, the values from that array will be passed as the object's properties
* - the object's properties which have no value assigned will be set to false to prevent name collisions in the mustache templates
*/