Skip to content

Instantly share code, notes, and snippets.

View thoriqmacto's full-sized avatar
🎯
Focusing

Thariq thoriqmacto

🎯
Focusing
View GitHub Profile
@thoriqmacto
thoriqmacto / PatternBuilder_Product.php
Created October 30, 2015 07:37
[PHP] Builder Design Pattern Example
<?php
class Product{
protected $_type = '';
protected $_size = '';
protected $_color = '';
public function setType($type){
$this->_type = $type;
}
@thoriqmacto
thoriqmacto / PatternDAO_User.php
Created October 30, 2015 09:13
[PHP] Data Access Object Pattern Example
<?php
abstract class baseDAO{
private $__connection;
public function __construct(){
$this->_connectToDB(DB_USER, DB_PASS, DB_HOST, DB_DATABASE);
}
private function __connectToDB($user, $pass, $host, $database){
@thoriqmacto
thoriqmacto / PatternDecorator_CD.php
Created November 3, 2015 03:27
[PHP] Decorator Pattern Example
<?php
class CD {
public $trackList;
public function __construct(){
$this->trackList = array();
}
public function addTrack($track){
$this->trackList[] = $track;
@thoriqmacto
thoriqmacto / ListAllFileInFolder.bas
Last active February 15, 2023 02:30
List all files inside the folder using VBA. Select cell containing full address of folder that want files to be listed
Sub ListFiles()
'Set a reference to Microsoft Scripting Runtime by using
'Tools > References in the Visual Basic Editor (Alt+F11)
'Declare the variables
Dim objFSO As Object
Dim objTopFolder As Object
Dim strTopFolderName As String
Dim flink As Range
@thoriqmacto
thoriqmacto / update_url.sql
Last active May 28, 2018 12:32
[sql] Update Specific URL Inside wp_posts Table
UPDATE wp_posts SET `post_content` = REPLACE (`post_content`, 'src="http://www.your-site.com"', 'src="https://www.your-site.com"');
UPDATE wp_2_posts SET `post_content` = REPLACE (`post_content`, 'src="http://www.your-site.com"', 'src="https://www.your-site.com"');
UPDATE wp_posts SET `guid` = REPLACE (`guid`, 'http://www.your-site.com', 'https://www.your-site.com') WHERE post_type = 'attachment';
UPDATE wp_2_posts SET `guid` = REPLACE (`guid`, 'http://www.your-site.com', 'https://www.your-site.com') WHERE post_type = 'attachment';
@thoriqmacto
thoriqmacto / runtype.js
Last active January 15, 2017 12:45
JavaScript function for run typing effect
function runTyping() {
var element = document.querySelector('#output');
var typeSpeed = 100; // 80 ms
var deleteSpeed = 30; // 30 ms
var deleteAfter = 1000; // 1 second
var items = [
"I sleep",
"I eat",
"I learn",
@thoriqmacto
thoriqmacto / GetRangeFromAnotherWB.xls
Last active September 3, 2017 06:10
[vba] Get Range from Another Workbook
Set raA = wkB.Names("BName").RefersToRange
@thoriqmacto
thoriqmacto / viewport.css
Created September 3, 2017 06:09
CSS media query for various viewport
/* Smartphones (portrait and landscape) ----------- */
@media only screen and (min-device-width : 320px) and (max-device-width : 480px) {
/* Styles */
}
/* Smartphones (landscape) ----------- */
@media only screen and (min-width : 321px) {
/* Styles */
}
@thoriqmacto
thoriqmacto / RecordsetDoLoop.bas
Created February 20, 2019 03:30
Recordset Iteration using Do ... Loop
rst.MoveFirst
Do Until rst.EOF = True
...
...
...
rst.MoveNext
Loop
@thoriqmacto
thoriqmacto / LoopShading.bas
Last active December 19, 2020 00:50
[VBA] Draw different color row shading based on LOOP tag.
Public Sub LoopShading()
Dim c As Range, bottomA As Long, curr As String, prev As String
Dim currColor As String, prevColor As String, tempcolor As String
bottomA = Range("A" & Rows.Count).End(xlUp).Row
currColor = "blue"
prevColor = "orange"
prev = "010-F-31001"
For Each c In Range("A2:A" & bottomA)
curr = c