Skip to content

Instantly share code, notes, and snippets.

View toocool's full-sized avatar

Shpëtim Islami toocool

  • Vienna, Austria
View GitHub Profile
#!/usr/bin/env bash
# Use this one-liner to produce a JSON literal from the Git log:
git log \
--pretty=format:'{%n "commit": "%H",%n "author": "%an <%ae>",%n "date": "%ad",%n "message": "%f"%n},' \
$@ | \
perl -pe 'BEGIN{print "["}; END{print "]\n"}' | \
perl -pe 's/},]/}]/'
@toocool
toocool / Mongo_model.php
Last active November 17, 2015 00:07
MongoDB adapter for Code igniter 2
<?php
/*
* 1. Add this file to libraries folder
* 2. Extend the Mongo_model class in your models (models directory) example: class User_model extends Mongo_model
* 3. add protected statis $collectionName = 'here the name of your mongo collection';
* 4. Load it in your controller, example: Mongo_model::load('user_model');
*/
class Mongo_Model
{
protected static $collectionName;
import re
def transform(input):
HTMLoutput = ""
for line in input.splitlines():
HTMLoutput = re.findall(r"(\w+)(\s+)(:)", line)
return HTMLoutput #return behen krejt qe jan be match
@toocool
toocool / test.js
Created December 23, 2016 12:42
get info from wikipedia
<script>
function dowiki(place) {
var URL = 'https://en.wikipedia.org/w/api.php?format=json&action=query&prop=extracts&exintro=&explaintext=';
URL += "&titles=" + place;
URL += "&rvprop=content";
URL += "&callback=?";
$.getJSON(URL, function (data) {
var obj = data.query.pages;
var ob = Object.keys(obj)[0];
@toocool
toocool / Datatables.php
Created January 1, 2017 04:21
Laravel custom class to handle data table queries coming from front end
<?php
namespace App\Classes;
use Illuminate\Pagination\LengthAwarePaginator;
class Datatables{
public static function of($query, $queryset){
//accept only the parameters inside this array
$params = $queryset->only(['sortBy', 'sortDirection','pageIndex','pageSize','searchBy','filterBy','filterWhere','filterValue']);
//check if filtering is enabled
@toocool
toocool / gist:076158a82840862be25841f093ce375c
Created January 24, 2017 14:24
datatable-alternate.php
<?php
namespace App\Support;
use Validator;
trait FilterPaginateOrder {
protected $operators = [
'equal_to' => '=',
'not_equal' => '<>',
'less_than' => '<',
'greater_than' => '>',
'less_than_or_equal_to' => '<=',
@toocool
toocool / bitbucket-pipelines.yml
Created March 6, 2020 15:18
Bitbucket yaml file for parallel Laravel deployment
image: atlassian/default-image:2
pipelines:
branches:
master:
- parallel:
- step:
name: "Zip the web code"
script:
- zip -r your-application.zip . -x "vendor/*"
@toocool
toocool / Dockerfile
Last active June 3, 2020 13:32
Dockerfile
RUN docker-php-ext-install opcache
RUN docker-php-ext-install pcntl
COPY .docker/php/php.ini /usr/local/etc/php
COPY .docker/php/opcache.ini /usr/local/etc/php/conf.d/opcache.ini
COPY start.sh /usr/local/bin/start
RUN chown -R www-data:www-data /var/www/html \
&& chmod u+x /usr/local/bin/start \
&& a2enmod rewrite
COPY . /var/www/html
@toocool
toocool / docker-compose.yml
Created June 3, 2020 12:55
docker compose file
version: "3"
services:
app:
container_name: projectname
build: .
depends_on:
- mysql
ports:
- "8000:80"
- "4433:443"
@toocool
toocool / start.sh
Created June 3, 2020 13:30
Bash script to execute artisan based on the env
#!/usr/bin/env bash
set -e
role=${CONTAINER_ROLE:-app}
env=${APP_ENV:-production}
if [ "$role" = "app" ]; then
exec apache2-foreground