Skip to content

Instantly share code, notes, and snippets.

View aliharis's full-sized avatar
💀

haris aliharis

💀
View GitHub Profile
@stankusl
stankusl / excerpt.md
Created May 27, 2015 15:07
Text Excerpt PHP function

Function:

function shorten_text($text, $max_length = 140, $cut_off = '...', $keep_word = false)
{
    if(strlen($text) <= $max_length) {
        return $text;
    }

if(strlen($text) > $max_length) {

@soufianeEL
soufianeEL / laravel.js
Last active June 18, 2023 05:25 — forked from JeffreyWay/laravel.js
You use Laravel 5 and you want to send a DELETE request without creating a form? This will handle the form-creation bits for you dynamically, similar to the Rails implementation. To use, import script, and create a link with the `data-method="DELETE"` and `data-token="{{csrf_token()}}"` attributes.
/*
Exemples :
<a href="posts/2" data-method="delete" data-token="{{csrf_token()}}">
- Or, request confirmation in the process -
<a href="posts/2" data-method="delete" data-token="{{csrf_token()}}" data-confirm="Are you sure?">
*/
(function() {
@tiagopassinato
tiagopassinato / async-lock.js
Last active August 27, 2022 07:41
NodeJS Async-lock example
/**
* Preventing dead-locks, using async-lock by key
*/
var AsyncLock = require('async-lock');
var lock = new AsyncLock();
function operation(id) {
console.log(id + " calling operation");
lock.acquire(id, function(done) {
@GhazanfarMir
GhazanfarMir / Instructions.sh
Last active December 22, 2024 01:12
Install PHP7.2 NGINX and PHP7.2-FPM on Ubuntu 16.04
########## Install NGINX ##############
# Install software-properties-common package to give us add-apt-repository package
sudo apt-get install -y software-properties-common
# Install latest nginx version from community maintained ppa
sudo add-apt-repository ppa:nginx/stable
# Update packages after adding ppa
@arikfr
arikfr / README.md
Last active May 21, 2025 13:28
Setting up HTTPS with LetsEncrypt for Redash Docker Deployment
  1. Make sure the domain you picked points at the IP of your Redash server.
  2. Switch to the root user (sudo su).
  3. Create a folder named nginx in /opt/redash.
  4. Create in the nginx folder two additional folders: certs and certs-data.
  5. Create the file /opt/redash/nginx/nginx.conf and place the following in it: (replace example.redashapp.com with your domain name)
    upstream redash {
        server redash:5000;
    }
    
@Mr-Malomz
Mr-Malomz / api.ts
Last active November 30, 2022 07:28
API Request
import axios, { AxiosResponse } from 'axios';
import { PostType } from '../models/post.interface';
const instance = axios.create({
baseURL: 'http://jsonplaceholder.typicode.com/',
timeout: 15000,
});
const responseBody = (response: AxiosResponse) => response.data;