Skip to content

Instantly share code, notes, and snippets.

View giuseppecrj's full-sized avatar

Giuseppe Rodriguez giuseppecrj

View GitHub Profile
@giuseppecrj
giuseppecrj / eip7702.ts
Created January 16, 2026 23:02
Bot EIP 7702
/**
* EIP-7702 Helper Utilities
*
* EIP-7702 allows EOAs to temporarily delegate their execution to a smart contract.
* This enables features like transaction batching, gas sponsorship, and custom logic
* while keeping the simplicity of an EOA.
*
* Usage:
* 1. Deploy BotAccountImpl contract (or use existing deployment)
* 2. Use sendDelegatedTransaction() for single calls
@giuseppecrj
giuseppecrj / readme.md
Created July 19, 2017 17:04
Github Batch Delete Repos

Use this trick to bulk delete your old repos or old forks

(Inspired by https://medium.com/@icanhazedit/clean-up-unused-github-rpositories-c2549294ee45#.3hwv4nxv5)

  1. Open in a new tab all to-be-deleted github repositores (Use the mouse’s middle click or Ctrl + Click) https://github.com/username?tab=repositories

  2. Use one tab https://chrome.google.com/webstore/detail/onetab/chphlpgkkbolifaimnlloiipkdnihall to shorten them to a list.

  3. Save that list to some path

  4. The list should be in the form of “ur_username\repo_name” per line. Use regex search (Sublime text could help). Search for ' |.*' and replace by empty.

@giuseppecrj
giuseppecrj / photo.server.controller.ts
Last active November 10, 2016 23:54
Upload Files to a Keystone.js Application through an API Endpoint
function create (req, res) {
const Photo = list('Photo') // keystone.js list
const item = new Photo.model()
const files = req.files // not needed but helpful if you have nested objects inside your list such as { gallery: photo: {type: keystone.types.File }}
// updateItem takes both a req.body and req.files so you can pass both of them in one post request.
Photo.updateItem(item, req.body, {
files,
}, (err) => {
if (err) return res.apiError('error', err)
lsof -i tcp:PORTNUMBER
kill -15 PID
// in case it doesn't work
killall -15 node
ps ax
@giuseppecrj
giuseppecrj / hover.js
Created November 24, 2015 18:28
Nav animation that follows the user's hover.
$(function() {
var $el, leftPos, newWidth,
$mainNav = $('.right');
var $active_one = $('.right li.active a');
$mainNav.append('<li id="magic-line"></li>');
var $magicLine = $('#magic-line');
$magicLine

Populating Data in KeystoneJS

Keystone's createItems function is a simple but powerful way to populate your database with data.

It can be used to create test fixtures or initialise your database with default content / users / etc.

There's also a shorthand syntax that can be used within update files; if you are using the auto updates feature, any file that exports a create object will automatically be wrapped and the data will be created.

createItems takes two passes at the data it is passed, first creating the items and retaining references by key (if provided) that can be used to populate relationships in the second pass. This makes it easy to create related data without asynchronous nesting (which for data creation sometimes ends up in knots).

var fs = require("fs");
var browserify = require("browserify"),
babelify = require("babelify"),
watchify = require('watchify'),
partialify = require('partialify');
var input = './www/js/commonjs/app.js',
output = './www/bundle.js',
debug = true;
@giuseppecrj
giuseppecrj / makefile
Created March 2, 2015 03:41
Express Structure Makefile
clean:
rm -r {app,config}
rm .gitignore
rm gruntfile.js
rm readme.md
rm server.js
build:
mkdir {app,config}
mkdir app/{controllers,routes,views,models}
@giuseppecrj
giuseppecrj / abstractFactory.js
Created February 17, 2015 03:51
Abstrat Factory for JS
// King class
var KingJoffery = (function() {
function KingJoffery() {}
KingJoffery.prototype.makeDecision = function() {
console.log('king has decided')
}
KingJoffery.prototype.marry = function() {}
return KingJoffery
})()