Skip to content

Instantly share code, notes, and snippets.

@di3
di3 / app.php
Last active Apr 24, 2019
laravel bootstrap/app.php for .env handling
View app.php
<?php
/*
.env
APP_ENV=local
.local.env
APP_DEBUG=true
.production.env
APP_DEBUG=false
*/
@di3
di3 / selectText.js
Created May 9, 2017
select text javascript
View selectText.js
//select text inside element
function selectText(e){
var t,n,o=document,a=window,c=o.body,l="unbdefined";
typeof a.getSelection!=l&&typeof o.createRange!=l?(n=o.createRange(),n.selectNodeContents(e),t=a.getSelection(),t.removeAllRanges(),t.addRange(n)) : typeof o.selection!=l&&typeof c.createTextRange!=l&&(n=c.createTextRange(),n.moveToElementText(e),n.select())
}
View toggle.js
function toggle(a){
a.style.display==="none"?a.style.display="block":a.style.display="none"
}
View getAbsoluteUrl.js
var getAbsoluteUrl=function(){
var a;return function(b){return a||(a=document.createElement("a")),a.href=b,a.href}
}();
// usage
getAbsoluteUrl('/di3'); // https://gist.github.com/di3
@di3
di3 / triggerResize.js
Created May 10, 2017
trigger resize event
View triggerResize.js
var e = document.createEvent("Events");
e.initEvent("resize", true, true);
window.dispatchEvent(e);
View debug .htaccess
php_flag display_startup_errors on
php_flag display_errors on
php_value error_reporting -1
php_value upload_max_filesize 20M
php_value post_max_size 21M
Action application/x-httpd-php70 /cgi-sys/php70-fcgi-starter.fcgi
AddType application/x-httpd-php70 .php .php70
View vim js to json
replace javascript object with json
:%s/\([A-z0-9]*\):/"\1":/g
@di3
di3 / City.php
Last active May 17, 2019
laravel city model
View City.php
<?php
namespace App\Models;
class City extends Model {
/**
* The database table used by the model.
* @var string
*/
protected $table = 'cities';
public $timestamps = false;
View disableTextSelection.js
export default {
WebkitTouchCallout: "none",
MozUserSelect: "none",
WebkitUserSelect: "none",
KhtmlUserSelect: "none",
msUserSelect: "none",
OUserSelect: "none",
userSelect: "none"
}
View array.js
export const shuffle = (array) => {
for (let i = array.length - 1; i > 0; i--) {
let rand = Math.floor(Math.random() * (i + 1));
[array[i], array[rand]] = [array[rand], array[i]]
}
}
export const filter = (arr, cb) => {
var r = [];
for (let i = 0, c = arr.length; i < c; i++) {