Skip to content

Instantly share code, notes, and snippets.

View jesseleite's full-sized avatar

Jesse Leite jesseleite

View GitHub Profile
@jesseleite
jesseleite / toggle_surrounding_quote_style.lua
Created December 21, 2023 04:53
Toggle surrounding quote style mapping in Neovim (probably not perfect lol!)
local toggle_surrounding_quote_style = function ()
local current_line = vim.fn.line('.')
local next_single_quote = vim.fn.searchpos("'", 'cn')
local next_double_quote = vim.fn.searchpos('"', 'cn')
if next_single_quote[1] ~= current_line then
next_single_quote = false
end
if next_double_quote[1] ~= current_line then
@jesseleite
jesseleite / swap.sh
Created April 9, 2016 15:30
1G Swap Forge Script/Recipe
if [ -f /swapfile ]; then
echo "Swapfile already exists."
exit 1
fi
fallocate -l 1G /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
sh -c 'echo "/swapfile none swap sw 0 0" >> /etc/fstab'
// cURL replacement for file_get_contents()
// Safer alternative to enabling allow_url_fopen in php.ini :)
function file_get_contents_curl($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
$data = curl_exec($ch);
curl_close($ch);
@jesseleite
jesseleite / minimal.lua
Created April 13, 2022 17:12
Minimal nvim config for nvim-treesitter testing
vim.cmd [[set runtimepath=$VIMRUNTIME]]
vim.cmd [[set packpath=/tmp/nvim/site]]
local package_root = '/tmp/nvim/site/pack'
local install_path = package_root .. '/packer/start/packer.nvim'
local function load_plugins()
require('packer').startup {
{
'wbthomason/packer.nvim',
{
'nvim-treesitter/nvim-treesitter',
function! ShtuffStrategy(cmd)
call system("shtuff into test " . shellescape("clear;" . a:cmd))
endfunction
let g:test#custom_strategies = {'shtuff': function('ShtuffStrategy')}
let g:test#strategy = "shtuff"
@jesseleite
jesseleite / SelectModifier.php
Created February 21, 2019 17:06
Statamic v2 array batch addon idea
<?php
namespace Statamic\Addons\ArrayBatch;
use Statamic\Extend\Modifier;
class SelectModifier extends Modifier
{
/**
* Modify a value
@jesseleite
jesseleite / gist:2ddf6961ffcce2c50e13
Last active August 28, 2018 12:43
Editor Wars and Sublime Text

I see 3 main types of code editors...

On one end of the spectrum we have powerful neckbeard editors like Vim and Emacs. These editors are language agnostic, offer a ton of raw text editing power, and can be heavily extended. These are CLI editors with no real GUI. They have the steepest learning curve.

At the other end of the spectrum we have powerful IDEs like PHPStorm, Visual Studio, etc. These editors are developed from the ground up around a specific set of languages. They encourage mouse use, and offer a ton of debugging and refactoring tools, etc. The main downside is speed, mostly due to their project indexing and code intelligence features.

The third type of editor bridges the gap between the above types. I think the two most popular editors right now are Sublime Text and Atom. My favourite of the two is Sublime Text. Sublime is blazing fast, and offers both neckbeard-like editing power and IDE-like code intelligence features through community packages. Here's my list of must-haves:

**Pa

<template>
<div class="tooltip-component" @mouseenter="show" @mouseleave="hide">
<div class="tooltip" :class="{ visible: isVisible }">
<span class="tooltip-text">{{ text }}</span>
</div>
<slot></slot>
</div>
</template>
<script>
@jesseleite
jesseleite / # php@7.1 - 2018-03-31_21-54-39.txt
Created April 2, 2018 15:09
php@7.1 on macOS 10.13.3 - Homebrew build logs
Homebrew build logs for php@7.1 on macOS 10.13.3
Build date: 2018-03-31 21:54:39
@jesseleite
jesseleite / sendString.js
Last active March 26, 2018 00:17
Digital Ocean console sendString() for pasting
var sendString = (function(rfb, force, sendDelay) {
sendDelay = sendDelay || 25;
var _q = [];
var _qStart = function() {
var chr = _q.shift();
if (chr) {
rfb.sendKey(chr);
setTimeout(_qStart, sendDelay);
}
};