Skip to content

Instantly share code, notes, and snippets.

View Pradeek's full-sized avatar

Pradeek Pradeek

  • HappyFox Technologies
  • Chennai, India
View GitHub Profile
#!/usr/bin/env python3
"""
PreToolUse hook that denies bare 'python' commands in uv projects.
Enforces using 'uv run python' for proper virtual environment isolation.
Only applies when project has uv indicators (pyproject.toml with uv.lock or .venv managed by uv).
Put this under ~/.claude/hooks/
"""
import json
import sys
import os
@Pradeek
Pradeek / localstorage-shim
Last active August 29, 2015 14:22
Local storage shim that works across old IEs and Safari's Private Browsing.
/***
* Local storage shim
* Taken from https://gist.github.com/remy/350433
* Local storage detection taken from https://gist.github.com/paulirish/5558557
* Modified to add {encode/decode}URIComponent to fix Safari's cookie semi-colon freak out.
***/
function doesLocalStorageEvenWork() {
try {
var str = "localStorage";
window.localStorage.setItem(str, str);
@Pradeek
Pradeek / vimrc
Created August 20, 2011 05:04
My .vimrc
set nocompatible " Forget vi.
call pathogen#infect() " Set up pathogen
syntax on
filetype plugin indent on
" Keep the buffer around when switching between buffers
set hidden
" Show what mode i'm in
@Pradeek
Pradeek / extend.js
Created August 15, 2011 14:37
Extending an object's properties with another. Kind of a stripped down version of jQuery.extend
function extend(destination, source, overwrite) {
if(typeof overwrite === 'undefined') {
overwrite = true;
}
for(var property in source) {
if(source.hasOwnProperty(property)) {
if(!destination[property] || overwrite) {
destination[property] = source[property];
}
}
@Pradeek
Pradeek / Model.js
Created May 11, 2011 04:17
NodeJS + MongoDB via Mongoose
var mongoose = require('mongoose');
mongoose.connect('YOUR_MONGODB_PATH');
var Schema = mongoose.Schema;
var ArticleSchema = new Schema({
id : String,
title : String,
body : String,
date : Date