Skip to content

Instantly share code, notes, and snippets.

@Noogic
Noogic / sort.js
Created January 29, 2021 12:35
add sort param to url
hastSort(key) {
if (! this.$page.props.query_params || ! this.$page.props.query_params.sort) {
return false;
}
const sortKeys = this.$page.props.query_params.sort.split(',');
if (sortKeys.includes(key)) {
return 'asc';
} else if (sortKeys.includes('-' + key)) {
return 'desc';
@Noogic
Noogic / GetFiles.php
Last active March 15, 2019 14:03
List files from S3/DO
<?
/**
* Use an structure with 'folder_name' as the bucket and the 'ID' as the folder name
* and naming files with 'order_name.ext'
* Example: /books/1 -> 1_pageone.jpg; 2_pagetwo.jpg
*/
public function getFilesAttribute()
{
$path = '/folder_name/' . $this->id;
$files = Storage::disk('spaces')->files($path);
@Noogic
Noogic / config.yml
Created December 4, 2018 11:14
CircleCi config for Laravel with phpunit, yarn test and dusk
version: 2
jobs:
build:
docker:
# specify the version you desire here
- image: circleci/php:7.2-cli-node-browsers-legacy
# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
# documented at https://circleci.com/docs/2.0/circleci-images/
@Noogic
Noogic / circle.yml
Last active October 25, 2018 09:45
Circle CI 2.0 for Laravel
version: 2
jobs:
build:
docker:
# specify the version you desire here
- image: circleci/php:7.1-cli-jessie-node-browsers
# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
# documented at https://circleci.com/docs/2.0/circleci-images/
@Noogic
Noogic / BaseBuilder.php
Last active May 12, 2018 11:02
Base for builders used to decorate entities in testing in laravel
<?php
namespace Database\Builders;
abstract class BaseBuilder
{
protected $entity;
protected $class;
public static function make(array $data = [])
@Noogic
Noogic / Getter.php
Created October 15, 2017 19:47
Getter
<?php
namespace App\Common;
trait Getter
{
public function __get($name)
{
if (method_exists($this, $name)) {
return $this->$name();
@Noogic
Noogic / create-swap.sh
Created August 2, 2017 00:09
Create swap
#!/bin/bash
fallocate -l 1G /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
# make it permanent
cp /etc/fstab /etc/fstab.bak
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
@Noogic
Noogic / set-locale.sh
Last active August 2, 2017 00:06
Locale in ubuntu
#!/bin/bash
locale-gen en_US en_US.UTF-8 es_ES es_ES.UTF-8
dpkg-reconfigure locales
@Noogic
Noogic / docker-install_ubuntu-trusty.sh
Last active July 21, 2016 10:22
Install docker and docker-compose in ubuntu 14.04
#!/bin/bash
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates -y
sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
echo 'deb https://apt.dockerproject.org/repo ubuntu-trusty main' | sudo tee --append /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
@Noogic
Noogic / nginxproxy.md
Created June 28, 2016 19:00 — forked from soheilhy/nginxproxy.md
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers