Skip to content

Instantly share code, notes, and snippets.

View bakpa79's full-sized avatar

Brian Akpa bakpa79

View GitHub Profile
// Referenced from http://ccoenraets.github.io/es6-tutorial-data/promisify/
let request = obj => {
return new Promise((resolve, reject) => {
let xhr = new XMLHttpRequest();
xhr.open(obj.method || "GET", obj.url);
if (obj.headers) {
Object.keys(obj.headers).forEach(key => {
xhr.setRequestHeader(key, obj.headers[key]);
});
@bakpa79
bakpa79 / gist:0161f9a9d8822a02a30934600bfffad4
Created March 6, 2020 18:32
Good looking Git logs using an alias
Found here: https://coderwall.com/p/euwpig/a-better-git-log
git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
I guess that's a bit too long, eh? Let's just make an alias. Copy and paste the line below on your terminal:
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
And every time you need to see your log, just type in
git lg
@bakpa79
bakpa79 / LICENSE.txt
Created February 20, 2019 19:48 — forked from jed/LICENSE.txt
generate random UUIDs
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Jed Schmidt <http://jed.is>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@bakpa79
bakpa79 / inject-registration-example
Last active September 28, 2018 15:00
Vue 2.x Inject registration syntax
//Parent component
export default Vue.extend({
props:{
propValue:{
required:false,
default:false,
type: Boolean
}
},
provide: function(){
<template lang="pug">
li(@click='$store.commit("UPDATE_SIDE_NAV_ACTIVE_ITEM", $el)')
slot
</template>
<script>
export default {
data () {
return {
provideData: {
// inputEl is the search <input> element,
//predictiveItemsEl is the container element for the predictive search list,
//predictiveItemsListEl is the <ul> list itself.
//I use this inside an object created from the search element.
function submitPredictivetext(inputEl, predictiveItemsEl, predictiveItemsListEl) {
var $this = jQuery(inputEl),
thisValue = $this[0].value,
thatValue="";
var timer = $this.data('timeout') || 500,
(function() {
var docEl = document.querySelectorAll('html');
docEl[0].setAttribute('data-useragent', navigator.userAgent);
/* IE10 and up no longer use the conditional IE hack - they are supposed to render very closely to what you find in WebkitGecko
But not really. So you still have to write conditional styles.
This is a small script that throws the browser's user-agent string on the <html> element. You can then write styles for thatt particular browser rendering.
For IE 10, 11, you use part of the string in your css to target the style declaration. NOTE: IE11's string is actually 'Trident/7.0'
$(document).ready(function() {
$("html.ie7 #primary-nav .sub .children > li:nth-child(4n)").after('<div class="clear"></div>');
// Hoverintent for Default Drop Down Navigation
function megaHoverOver(){
$(this).find(".sub").stop().fadeTo('fast', 1).show();
$(this).find(".sub .children > li:nth-child(4n+1)").css({'clear' : 'both'});
};