Skip to content

Instantly share code, notes, and snippets.

Avatar
🤠
--- 200 OK

Xander Smalbil xtrasmal

🤠
--- 200 OK
  • Video Funk
  • Enschede, Netherlands
View GitHub Profile
@xtrasmal
xtrasmal / Chromium Mobile Device List
Created Mar 6, 2020 — forked from devinmancuso/Chromium Mobile Device List
Mobile Device Emulation List from Chromium
View Chromium Mobile Device List
#Pulled from Chromium at: https://code.google.com/p/chromium/codesearch#chromium/src/third_party/WebKit/Source/devtools/front_end/toolbox/OverridesUI.js&q=WebInspector.OverridesUI._phones%20file:OverridesUI.js&sq=package:chromium&type=cs&l=310
#Phones
Define_phones = [
{deviceName: "Apple iPhone 3GS", width: 320, height: 480, deviceScaleFactor: 1, userAgent: "Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_2_1 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8C148 Safari/6533.18.5", touch: true, mobile: true},
{deviceName: "Apple iPhone 4", width: 320, height: 480, deviceScaleFactor: 2, userAgent: "Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_2_1 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8C148 Safari/6533.18.5", touch: true, mobile: true},
{deviceName: "Apple iPhone 5", width: 320, height: 568, deviceScaleFactor: 2, userAgent: "Mozilla/5.0 (iPhone; CPU iPhone OS 7_0 like Mac OS X; en-us) AppleWebKit/537.51.1 (KHTML, like Gecko) Versi
@xtrasmal
xtrasmal / AppLayout.js
Created Apr 13, 2019 — forked from unr/AppLayout.js
Bare Minimum Laravel Echo in Nuxt.JS example.
View AppLayout.js
// In my global app layout, once my app is mounted and ready to listen...
import { mapActions, mapGetters } from 'vuex';
const Layout = {
mounted() {
// set up pusher listeners
this.connectToPublicChannel();
this.$watch('authenticated', (auth) => {
if (auth) this.connectToUserChannel();
@xtrasmal
xtrasmal / Countdown.vue
Last active Mar 20, 2019
VueJS Flip countdown flip clock using momentjs
View Countdown.vue
<script>
import * as moment from 'moment-timezone'
export default {
props: {
date: {
required: true,
default: moment().format()
},
locale: {
@xtrasmal
xtrasmal / 1.Usage.php
Last active Dec 11, 2018
Redis HashTable Open Addressing, probing. Hashing, create an index based on the value of the item that needs to be stored.
View 1.Usage.php
<?php
// Add stuff to redis
foreach ($userIds as $uuid) {
$this->indexer->addAtIndex("users", $uuid);
}
// later... retrieve from redis
$userID = "fa5352f9-fa1b-48c9-862d-1cb614cc7ed8";
$user = $this->indexer->getAtIndex("users", $userID);
@xtrasmal
xtrasmal / 1.test.php
Created Dec 3, 2018
php hash functions metrics results(see comment at: http://php.net/manual/en/function.hash.php)
View 1.test.php
<?php
echo "Building data...";
$data = "";
for($i = 0; $i < 1500; $i++)
$data .= sha1("H:k - $i - k:H");
echo "OK! (".strlen($data)." bytes)".PHP_EOL;
$res = [];
@xtrasmal
xtrasmal / cs-fix.sh
Created Aug 2, 2018
PHP CS Fixer CLI
View cs-fix.sh
#!/bin/bash
PHP=`which php`
$PHP php-cs-fixer fix app --rules='{"@PSR2":true,"array_indentation": true,"array_syntax": {"syntax":"short"},"no_unused_imports": true,"object_operator_without_whitespace": true,"ordered_class_elements": {"sortAlgorithm": "none"},"ordered_imports": {"sortAlgorithm": "length"}}'
View Repository.php
<?php
class Repository
{
public function findAll(): array
{
return $this->connection->project(
sprintf('SELECT * FROM %s', self::TABLE_NAME),
[],
function(array $row): Domain\MyObject {
return Domain\MyObject::fromArray($row);
View alter_all_tables_collation.mysql
SELECT CONCAT("ALTER TABLE ",TABLE_SCHEMA,".",TABLE_NAME," CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; ",
"ALTER TABLE ",TABLE_SCHEMA,".",TABLE_NAME," CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; ")
AS alter_sql
FROM information_schema.TABLES
WHERE TABLE_SCHEMA = 'mist';
@xtrasmal
xtrasmal / Guarded.php
Created Apr 2, 2018
Guarded FormRequest
View Guarded.php
<?php
/**
* Trait Guarded
* use in a Laravel FormRequest class
*/
trait Guarded
{
/**
* Get all input parameter that are guarded by and
* match the rules array of the form request
@xtrasmal
xtrasmal / user.service.ts
Created Oct 10, 2017
Angular user service
View user.service.ts
import { Injectable } from '@angular/core';
import { Http, Headers, RequestOptions, Response } from '@angular/http';
import { User } from '../_models/index';
@Injectable()
export class UserService {
constructor(private http: Http) { }
getAll() {