Skip to content

Instantly share code, notes, and snippets.

[Desktop]
https://myip.ms/browse/comp_browseragents/Computer_Browser_Agents.html
[All]
https://udger.com/resources/ua-list
http://www.useragentstring.com/pages/useragentstring.php
https://deviceatlas.com/blog/list-of-user-agent-strings
[PHP redirect script]
if ($version != "desktop") {
$useragent=$_SERVER['HTTP_USER_AGENT'];
if(preg_match('/android|avantgo|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\\/|plucker|pocket|psp|symbian|treo|up\\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i',$useragent)||preg_match('/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\\-(n|u)|c55\\/|capi|ccwa|cdm\\-|cell|chtm|cldc|cmd\\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\\-s|devi|dica|dmob|do(c|p)o|ds(12|\\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)
var kryoPrefetch = {
_init: function() {
debug = true;
store = {
clicked: undefined,
mouseDown: false,
targetMatch: false,
pending: false,
href: ""
};
@c7x43t
c7x43t / $$.js
Last active March 22, 2018 08:23
merc={
_kEquip:function(e){
e.setDefaultValue=function(value){
if(!(e instanceof Array)) e=merc._Array.from(e);
e.map(e=>{
e.value=value;
e.addEventListener("focusin",(e)=>{
if(e.target.value===value) e.target.value="";
});
e.addEventListener("focusout",(e)=>{
.font-smoothing {
/* Adjust font size */
font-size: 100%;
-webkit-text-size-adjust: 100%;
/* Font varient */
font-variant-ligatures: none;
-webkit-font-variant-ligatures: none;
/* Smoothing */
font-smooth: always;
text-rendering: optimizeLegibility;
@c7x43t
c7x43t / serialize.js
Last active April 29, 2018 11:08
serialize <input>
function serialize(form){
if (!form || form.nodeName !== "FORM") return;
var el, op, obj = {}, name, type, value, node;
for (el of form.elements) {
name=el.name;
if (name === "") continue;
type=el.type;
value=el.value;
node=el.nodeName;
if(/INPUT/.exec(node) && (/text|hidden|password|button|reset|submit/.exec(type) || /checkbox|radio/.exec(type)&&el.checked) ||
@c7x43t
c7x43t / round n to m decimals.js
Last active May 9, 2018 09:40
roundN(1.005,2) -> 1.01
function roundN(n,m){
return Math.round(n*Math.pow(10,m)+72e-16)/Math.pow(10,m);
}
// https://mozilla.github.io/server-side-tls/ssl-config-generator/
server {
listen 80 default_server;
listen [::]:80 default_server;
# Redirect all HTTP requests to HTTPS with a 301 Moved Permanently response.
return 301 https://$host$request_uri;
}
server {
// Benchmarking function (array of functions, iterations, array of arguments)
function benchmark(func,n,args){
// analyze arguments passed: empty or num/string or array
if (typeof args ==='undefined'){
args=[];
}else if(typeof args[0]==='undefined' || typeof args==='string'){
args=[args];
}
// analyze functions
if (typeof func==="function") {func=[func]}
// subClass returns a constructor wrapper function that has all the methods in the subclass Prototype,
// while keeping the original return type's prototype
// when to use? augmenting objects generated by classes with methods.
// since it is a wrapper also native classes like Array, String, Number can safely be extended
// adding methods to returned objects is also reasonably fast this way, because only the Prototype needs to be set
function subClass(constructor, returnType, methods) {
function collector() {}
methods = methods ? methods instanceof Array ? methods : [methods] : [];
const subConstructor = function() {
const obj = constructor(...arguments);
(function(global) {
// Instead of looping trough all possibilities a object property lookup is used
// The object construction is in addition memoized, since it's relatively expensive
var hashFindHash = {};
function hashFind(str, hash, delimiter) {
delimiter = delimiter || ";";
if (hashFindHash.hasOwnProperty(hash)) {
return hashFindHash[hash].hasOwnProperty(str);
} else {