Skip to content

Instantly share code, notes, and snippets.

Avatar

Nate Adams n8jadams

View GitHub Profile
@liitfr
liitfr / README.md
Last active Jul 10, 2020
[how to revert 100644 → 100755 commits ?] #git #chmod
View README.md

how to revert 100644 → 100755 commits

  • on your repo's root, run : find . -type f | xargs chmod -x
  • commit this change on files : commit -n -m 'fix: files permission from 100755 to 100644'
  • then with vim .git/config, set filemode option to false
[core]
        filemode = false
@ziggi
ziggi / parents.js
Last active Jul 2, 2020
Vanilla JS jQuery.parents() realisation (npm module: https://github.com/ziggi/dom-parents)
View parents.js
Element.prototype.parents = function(selector) {
var elements = [];
var elem = this;
var ishaveselector = selector !== undefined;
while ((elem = elem.parentElement) !== null) {
if (elem.nodeType !== Node.ELEMENT_NODE) {
continue;
}
@JayWood
JayWood / closetags.php
Created Jul 18, 2014
Close ALL open HTML tags in PHP string
View closetags.php
<?php
function closetags($html) {
preg_match_all('#<([a-z]+)(?: .*)?(?<![/|/ ])>#iU', $html, $result);
$openedtags = $result[1];
preg_match_all('#</([a-z]+)>#iU', $html, $result);
$closedtags = $result[1];
$len_opened = count($openedtags);
@lastguest
lastguest / JSON_to_URLEncoded.js
Created Jul 10, 2014
Convert JavaScript object to x-www-form-urlencoded format
View JSON_to_URLEncoded.js
function JSON_to_URLEncoded(element,key,list){
var list = list || [];
if(typeof(element)=='object'){
for (var idx in element)
JSON_to_URLEncoded(element[idx],key?key+'['+idx+']':idx,list);
} else {
list.push(key+'='+encodeURIComponent(element));
}
return list.join('&');
}
You can’t perform that action at this time.