Skip to content

Instantly share code, notes, and snippets.

View mubaidr's full-sized avatar
🎯
Adding bugs to web applications!

Muhammad Ubaid Raza mubaidr

🎯
Adding bugs to web applications!
View GitHub Profile
@tduarte
tduarte / publish-ghpages.md
Last active May 8, 2025 12:36
If you need to force push an subtree
git checkout master # you can avoid this line if you are in master...
git subtree split --prefix dist -b gh-pages # create a local gh-pages branch containing the splitted output folder
git push -f origin gh-pages:gh-pages # force the push of the gh-pages branch to the remote gh-pages branch at origin
git branch -D gh-pages # delete the local gh-pages because you will need it: ref
@lukechilds
lukechilds / get_latest_release.sh
Created August 9, 2016 19:43
Shell - Get latest release from GitHub
get_latest_release() {
curl --silent "https://api.github.com/repos/$1/releases/latest" | # Get latest release from GitHub api
grep '"tag_name":' | # Get tag line
sed -E 's/.*"([^"]+)".*/\1/' # Pluck JSON value
}
# Usage
# $ get_latest_release "creationix/nvm"
# v0.31.4
@xem
xem / readme.md
Last active April 18, 2025 20:19
Maths & trigonometry cheat sheet for 2D & 3D games

Conventions

  • A = [xA, yA] is a point on the 2D plane. Same for B, C, ...
  • lengths are in any unit (ex: pixels)
  • code snippets are in JavaScript

Degrees to radians

angleRad = angleDeg * Math.PI / 180;

@manuelbieh
manuelbieh / sequelize-schema-file-generator.js
Last active April 5, 2025 20:02
Automatically generates migration files from your sequelize models
import * as models from "models";
import Sequelize from "sequelize";
import fs from "fs";
delete models.default;
const sequelize = new Sequelize(
'',
'',
'', {
@alexpchin
alexpchin / socket-cheatsheet.js
Created December 15, 2015 16:58
A quick cheatsheet for socket.io
// sending to sender-client only
socket.emit('message', "this is a test");
// sending to all clients, include sender
io.emit('message', "this is a test");
// sending to all clients except sender
socket.broadcast.emit('message', "this is a test");
// sending to all clients in 'game' room(channel) except sender
@rponte
rponte / get-latest-tag-on-git.sh
Last active December 9, 2024 00:27
Getting latest tag on git repository
# The command finds the most recent tag that is reachable from a commit.
# If the tag points to the commit, then only the tag is shown.
# Otherwise, it suffixes the tag name with the number of additional commits on top of the tagged object
# and the abbreviated object name of the most recent commit.
git describe
# With --abbrev set to 0, the command can be used to find the closest tagname without any suffix:
git describe --abbrev=0
# other examples
@tanveery
tanveery / Startup.cs
Last active December 26, 2016 15:09
LinkedIn APIs for .NET
public void ConfigureAuth(IAppBuilder app)
{
// ...
var linkedInOptions = new LinkedInAuthenticationOptions();
linkedInOptions.ClientId = "Your LinkedIn API Key";
linkedInOptions.ClientSecret = "Your LinkedIn Secret Key";
linkedInOptions.Scope.Add("r_fullprofile");
@soyuka
soyuka / global.js
Last active August 29, 2015 14:07
Opinion about global wrappers in nodejs
//global variable
test = 'hello';
//is exactly the same as
global.test = 'hello';
//local variable - this will definitly override your global variable
var test = 'hello';
//using the process scope, if, and really if, you can't do without a global variable
@addyosmani
addyosmani / README.md
Last active May 10, 2025 11:24 — forked from 140bytes/LICENSE.txt
108 byte CSS Layout Debugger

CSS Layout Debugger

A tweet-sized debugger for visualizing your CSS layouts. Outlines every DOM element on your page a random (valid) CSS hex color.

One-line version to paste in your DevTools

Use $$ if your browser aliases it:

~ 108 byte version

@dennisseah
dennisseah / gist:e9e74b7a55816dba2628
Created August 24, 2014 22:39
Javascript: Module Pattern to define a class
// Javascript module pattern to define class
// having private and public members and functions
var Cat = (function() {
// private member
var _name = null;
// constructor
function Cat(name) {
_name = name; // this one is private