Skip to content

Instantly share code, notes, and snippets.

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

Muhammad Ubaid Raza mubaidr

:shipit:
Adding bugs to web applications!
View GitHub Profile
<div id="consolelog" style="font-family: 'Courier New', Courier, monospace; font-size: 12px; margin: 40px 30px 0px; background-color: white; border: 2px solid black; padding: 10px;"></div>
<input type="text" id="consoleinput" style="margin: 0px 30px; width: 400px;" onkeypress="return evalConsoleInput(event, this.value);" />
<script type="text/javascript">
var appendConsole = function(message, type) {
var color = "black";
if (type === "error") {
color = "red";
} else if (type === "debug") {
@mubaidr
mubaidr / README.md
Last active August 29, 2015 14:07 — forked from addyosmani/README.md

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

@mubaidr
mubaidr / memorySizeOfObject.js
Created April 4, 2016 10:52
calculate memory size of javascript object, it is not a accurate value!
function memorySizeOf(obj) {
var bytes = 0;
function sizeOf(obj) {
if(obj !== null && obj !== undefined) {
switch(typeof obj) {
case 'number':
bytes += 8;
break;
case 'string':
@mubaidr
mubaidr / Startup.cs
Created December 26, 2016 15:09 — forked from tanveery/Startup.cs
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");
@mubaidr
mubaidr / get_barcode_from_image.js
Created May 6, 2018 16:57 — forked from tobitailor/get_barcode_from_image.js
Barcode recognition with JavaScript - Demo: http://bit.ly/djvUoy
/*
* Copyright (c) 2010 Tobias Schneider
* This script is freely distributable under the terms of the MIT license.
*/
(function(){
var UPC_SET = {
"3211": '0',
"2221": '1',
"2122": '2',
@mubaidr
mubaidr / index.html
Created July 25, 2018 16:50 — forked from mac2000/index.html
brain.js demo
<!DOCTYPE html>
<html>
<head>
<title>brain.js</title>
<script src="https://cdn.rawgit.com/BrainJS/brain.js/develop/browser.js"></script>
<script>
function DrawableCanvas(el) {
const px = 10
const ctx = el.getContext('2d')
let x = []
@mubaidr
mubaidr / sequelize-schema-file-generator.js
Last active December 27, 2018 04:46 — forked from manuelbieh/sequelize-schema-file-generator.js
Automatically generates migration files from your sequelize models
const fs = require('fs')
const { sequelize } = require('./api/db/models')
const { models } = sequelize
function toSnakeCase(str, upper) {
if (str.split().every(s => s.toLowerCase() === s)) return str
const snake = str.replace(/([A-Z])/g, $1 => `_${$1.toLowerCase()}`)
@mubaidr
mubaidr / migrate-assert-to-expect.js
Created August 14, 2019 13:46 — forked from robertleeplummerjr/migrate-assert-to-expect.js
A script that migrates from using assert to jest's expect
const { parse } = require('acorn');
const fs = require('fs');
const file = fs.readFileSync('./__tests__/file-name.js').toString();
const rootAST = parse(file, {
locations: true
});
function traverse(ast) {
if (Array.isArray(ast)) {
for (let i = 0; i < ast.length; i++) {
@mubaidr
mubaidr / gh-pages-deploy.md
Created August 16, 2019 17:49 — forked from cobyism/gh-pages-deploy.md
Deploy to `gh-pages` from a `dist` folder on the master branch. Useful for use with [yeoman](http://yeoman.io).

Deploying a subfolder to GitHub Pages

Sometimes you want to have a subdirectory on the master branch be the root directory of a repository’s gh-pages branch. This is useful for things like sites developed with Yeoman, or if you have a Jekyll site contained in the master branch alongside the rest of your code.

For the sake of this example, let’s pretend the subfolder containing your site is named dist.

Step 1

Remove the dist directory from the project’s .gitignore file (it’s ignored by default by Yeoman).

@mubaidr
mubaidr / get-latest-tag-on-git.sh
Created March 24, 2020 13:58 — forked from rponte/get-latest-tag-on-git.sh
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