Skip to content

Instantly share code, notes, and snippets.

View fadlee's full-sized avatar

Fadlul Alim fadlee

  • Indonesia
  • 03:56 (UTC +07:00)
View GitHub Profile
@fadlee
fadlee / image-shortcode.php
Created April 11, 2012 12:08 — forked from kovshenin/image-shortcode.php
Image shortcode for WordPress
<?php
/**
* Image shortcode callback
*
* Enables the [kovshenin_image] shortcode, pseudo-TimThumb but creates resized and cropped image files
* from existing media library entries. Usage:
* [kovshenin_image src="http://example.org/wp-content/uploads/2012/03/image.png" width="100" height="100"]
*
* @uses image_make_intermediate_size
*/
@fadlee
fadlee / helpers.js
Created June 30, 2013 13:31
Javascript Functions
//How can I get query string values?
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
function setCookie(c_name,value,exdays)
{
@fadlee
fadlee / _wp.sass
Created July 25, 2013 23:39
Wordpress basic article style
.article
blockquote
font-style: italic
table
border: 1px solid #e7e7e7
text-align: left
width: 100%
margin: 0 -1px 24px 0
@fadlee
fadlee / mysql_countries.sql
Created January 30, 2016 06:51 — forked from kamermans/mysql_countries.sql
MySQL Dump - continents and countries with 2 and 3 char codes, names and full names - Braintree compatible as of Dec 2011
/**
* Continents and Countries MySQL Tables compiled from Wikipedia, Braintree Payments documentation
* and a couple other places I don't recall at the moment. This data is compatible with the Braintree
* Payment API as of Dec 2011
*
* Compiled by Steve Kamerman, 2011
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
@fadlee
fadlee / custom-upload-folder.php
Last active September 27, 2018 02:34
WP Custom Upload Folder
<?php
/*
Plugin Name: Custom Upload Folder
Description: Upload files to custom directory in WP Media Library.
Version: 1.0.0
Author: Notekar
Author URI: https://motekar.com/
Text Domain: custom-upload-folder
*/
@fadlee
fadlee / git-backup.sh
Last active June 30, 2020 10:17
Git as a time machine for file backup
#!/bin/bash
gitstatus=`git status -s -uall`
curtime=`date`
# Check if has changes
if echo $gitstatus | grep "."; then
git add .
git commit -m "Automatic Backup @ $curtime
@fadlee
fadlee / README.md
Created December 3, 2021 17:52 — forked from djfdyuruiry/README.md
WSL 2 - Enabling systemd

Enable systemd in WSL 2

This guide will enable systemd to run as normal under WSL 2. This will enable services like microk8s, docker and many more to just work during a WSL session. Note: this was tested on Windows 10 Build 2004, running Ubuntu 20.04 LTS in WSL 2.

  • To enable systemd under WSL we require a tool called systemd-genie

  • Copy the contents of install-sg.sh to a new file /tmp/install-sg.sh:

    cd /tmp
@fadlee
fadlee / .zshrc
Created December 16, 2021 23:15
Auto switch node version using fnm with zsh shell
eval "`fnm env`"
# do this after eval fnm env
auto-fnm-use() {
if [[ -f .nvmrc && -r .nvmrc ]] || [[ -f .node-version && -r .node-version ]]; then
fnm use
elif [[ `node -v` != `~/.fnm/aliases/default/bin/node -v` ]]; then
echo Reverting to node from "`node -v`" to "`~/.fnm/aliases/default/bin/node -v`"
fnm use default
fi

Laravel-Google Sheets Two-Way Synchronization (Using Google Apps Script)

This guide will help you create a bidirectional synchronization system between Laravel and Google Sheets using Google Apps Script to handle the connection, without requiring the Google Sheets API.

Overview of the Solution

  1. Google Apps Script Setup: Create a web app that exposes REST endpoints for your Laravel app to interact with the spreadsheet
  2. Laravel Project Setup: Create models, services, and controllers to handle the data
  3. Two-Way Synchronization: Set up bidirectional sync between Google Sheets and Laravel