Skip to content

Instantly share code, notes, and snippets.

View biranchi2018's full-sized avatar

Biranchi biranchi2018

  • Bangalore, India
View GitHub Profile
@biranchi2018
biranchi2018 / learn_gpt2.py
Last active May 21, 2026 01:09
GPT2 Model
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
tokenizer = AutoTokenizer.from_pretrained("distilgpt2")
model = AutoModelForCausalLM.from_pretrained("distilgpt2", output_hidden_states=True)
print(model)
print(model.lm_head)
print(model.transformer.wte) # Dimensions are: (Number of tokens in vocabulary, dimension of model)
print(model.transformer.wte(torch.tensor(464)))
@biranchi2018
biranchi2018 / remove_widgets.py
Created May 15, 2026 02:42
Remove 'metadata.widgets' entry from Google Colab notebook
%%writefile remove_widgets.py
# pip install nbformat
import nbformat
from nbformat import v4
import glob
def remove_widgets_metadata(notebook_path):
"""Removes the 'metadata.widgets' entry from the notebook, preserving cell outputs."""
@upkarlidder
upkarlidder / dl-resources.md
Last active June 18, 2022 08:32
Deep Learning Hands-On Series with Eric Schles
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@biranchi2018
biranchi2018 / luhn.js
Created September 21, 2016 04:56 — forked from ShirtlessKirk/luhn.js
Luhn validation algorithm
/**
* Luhn algorithm in JavaScript: validate credit card number supplied as string of numbers
* @author ShirtlessKirk. Copyright (c) 2012.
* @license WTFPL (http://www.wtfpl.net/txt/copying)
*/
var luhnChk = (function (arr) {
return function (ccNum) {
var
len = ccNum.length,
bit = 1,
@joseluisq
joseluisq / terminal-git-branch-name.md
Last active April 13, 2026 22:07
Add Git Branch Name to Terminal Prompt (Linux/Mac)

Add Git Branch Name to Terminal Prompt (Linux/Mac)

image

Open ~/.bash_profile in your favorite editor and add the following content to the bottom.

# Git branch in prompt.

parse_git_branch() {
@prime31
prime31 / gist:5675017
Last active October 27, 2025 01:52
Simple PHP script showing how to send an Android push notification. Be sure to replace the API_ACCESS_KEY with a proper one from the Google API's Console page. To use the script, just call scriptName.php?id=THE_DEVICE_REGISTRATION_ID
<?php
// API access key from Google API's Console
define( 'API_ACCESS_KEY', 'YOUR-API-ACCESS-KEY-GOES-HERE' );
$registrationIds = array( $_GET['id'] );
// prep the bundle
$msg = array
@ShirtlessKirk
ShirtlessKirk / luhn.js
Last active December 31, 2025 09:18
Luhn validation algorithm
/**
* Luhn algorithm in JavaScript: validate credit card number supplied as string of numbers
* @author ShirtlessKirk. Copyright (c) 2012.
* @license WTFPL (http://www.wtfpl.net/txt/copying)
*/
var luhnChk = (function (arr) {
return function (ccNum) {
var
len = ccNum.length,
bit = 1,
@rjungemann
rjungemann / Communicator.h
Created June 21, 2010 00:45
How to open a TCP socket in Objective-C
#import <Foundation/Foundation.h>
@interface Communicator : NSObject <NSStreamDelegate> {
@public
NSString *host;
int port;
}
- (void)setup;