Skip to content

Instantly share code, notes, and snippets.

View ignasbernotas's full-sized avatar
🎉

Ignas Bernotas ignasbernotas

🎉
View GitHub Profile
@ignasbernotas
ignasbernotas / coroutine.php
Last active July 6, 2022 00:16
Swoole coroutines
<?php
use Swoole\Coroutine as Co;
Co\run(function () {
for ($i = 0; $i < 100; $i++) {
go(function () use($i) {
usleep(1_000_00 * mt_rand(1,10));
echo "Coroutine $i is done.\n";
});
@ignasbernotas
ignasbernotas / SetModelAttributes.php
Last active July 5, 2022 12:53
A super simple artisan command to generate setting model properties
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
class SetModelAttributes extends Command
{
@ignasbernotas
ignasbernotas / mac-swoole.sh
Created July 2, 2022 19:05
Mac install PHP Swoole extension
echo 'export PATH="/usr/local/opt/openssl@3/bin:$PATH"' >> ~/.zshrc
echo 'export LDFLAGS="-L/usr/local/opt/openssl@3/lib"' >> ~/.zshrc
echo 'export CPPFLAGS="-I/usr/local/opt/openssl@3/include"' >> ~/.zshrc
echo 'export PKG_CONFIG_PATH="/usr/local/opt/openssl@3/lib/pkgconfig"' >> ~/.zshrc
brew install pcre2
brew reinstall openssl && brew unlink openssl && brew link openssl --force
pecl install swoole
@ignasbernotas
ignasbernotas / bootstrap.sh
Last active May 1, 2023 14:34
MacBook setup script
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install zsh zsh-syntax-highlighting terraform nvm wget ab wrk nano gpg
# nano highlighting
curl https://raw.githubusercontent.com/scopatz/nanorc/master/install.sh | sh
# Oh my ZSH
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
@ignasbernotas
ignasbernotas / bootstrap.sh
Last active September 16, 2021 22:41
Gatsby + Tailwind bootstrap script
PROJECT_NAME="ignas.tech"
# Replace the line of the given line number with the given replacement in the given file.
function replace_string() {
local file="$1"
local find="$2"
local replacement="$3"
# Escape replacement
replacement_escaped=$(echo "$replacement" | sed -e 's/[]\/$*.^[]/\\&/g')
import React from 'react'
import { Root } from 'native-base'
import { createDrawerNavigator, createStackNavigator } from 'react-navigation'
import { Dimensions } from 'react-native'
import About from './screens/about'
import Home from './screens/home'
import Sidebar from './screens/sidebar'
import Splash from './screens/splash'
const deviceWidth = Dimensions.get('window').width
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateJobsTable extends Migration
{
/**
* Run the migrations.
@ignasbernotas
ignasbernotas / setup.sh
Last active June 3, 2017 08:44
OSX Setup
#!/bin/sh
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew tap caskroom/cask
brew cask install google-chrome iterm2 sequel-pro vagrant virtualbox slack spotify boom bettertouchtool vlc phpstorm basecamp bittorrent zsh
brew install git
mv /usr/local/Caskroom/bittorrent/latest/Bittorrent.app /Applications/Bittorrent.app
<?php
namespace App\Libraries\Date;
use Carbon\Carbon;
/**
* Class DateRange
*
* @package App\Libraries\Date
@ignasbernotas
ignasbernotas / relationships.js
Last active October 18, 2016 01:13
Dexie relationship loading plugin
import Dexie from 'dexie'
/**
* Usage: db.table_a.with('table_a_children', 'parent_id', 'children', 'id')
*
* This will return all items from table 'table_a'
* where each item will have a 'children' array with linked records from 'table_a_children' table
*/
Dexie.addons.push((db) => {
/**