Skip to content

Instantly share code, notes, and snippets.

@SubZane
SubZane / update a fork
Created August 30, 2016 07:51
update a fork
// Check out the branch you wish to merge to. Usually, you will merge into master.
git checkout master
// Pull the desired branch from the upstream repository. This method will retain the commit history without modification.
git pull https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git BRANCH_NAME
@SubZane
SubZane / move git tag
Created August 30, 2016 07:42
Move git tag to last commit
git push origin :refs/tags/1.0.0
git tag -f "1.0.0"
git push origin master --tags
@SubZane
SubZane / forcerepaint.js
Created August 25, 2016 08:34
Force the repaint of an element. Sometimes necessary when adding CSS rules after document loaded.
// Force the repaint of an element. Sometimes necessary when adding CSS rules after document loaded.
function forceRepaint(element) {
element.style.display='none';
var temp = element.offsetHeight;
element.style.display='';
}
@SubZane
SubZane / hasVerticalScroll.js
Created August 17, 2016 11:28
Detects if there is a visible horizontal scrollbar
function hasVerticalScroll() {
var scrollHeight = document.body.scrollHeight;
var clientHeight = document.documentElement.clientHeight;
var hasVerticalScrollbar = scrollHeight > clientHeight;
return hasVerticalScrollbar;
}
@SubZane
SubZane / detectScrollbarWidth.js
Last active August 17, 2016 11:29
detects the width of the scrollbar. Different depending on OS and browser.
function detectScrollbarWidth() {
var outer = document.createElement('div');
outer.style.visibility = 'hidden';
outer.style.width = '100px';
outer.style.msOverflowStyle = 'scrollbar'; // needed for WinJS apps
document.body.appendChild(outer);
var widthNoScroll = outer.offsetWidth;
// force scrollbars
@SubZane
SubZane / gist:3f5206fb439d080a8680
Last active May 14, 2023 18:02
Regex to remove empty html tags
<(\w+)\b(?:\s+[\w\-.:]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[\w\-.:]+))?)*\s*/?>\s*</\1\s*>
@SubZane
SubZane / gist:9307cefafea4ba746a38
Last active August 17, 2016 11:30
css center absolute
.center_absolute_positioned {
position: absolute;
margin-left: auto;
margin-right: auto;
left: 0;
right: 0;
}
@SubZane
SubZane / Detect Windows Tablet or Laptop
Created October 13, 2015 13:42
Detect Windows Tablet or Laptop
window.PointerEvent ? "pointer" : "ontouchstart" in window ? "touch" : "mouse";
$ setxkbmap -option apple:badmap
# Place that command into ~/.bashrc file to have it run automatically when you log in.
sudo su
mkdir /mnt/timecapsule
echo "//timeCapsuleIp/Data /mnt/toshiba cifs user= timecapsuleUsername,pass= timecapsuleUserPassword,rw,uid=1000,iocharset=utf8,sec=ntlm 0 0" >> /etc/fstab