Skip to content

Instantly share code, notes, and snippets.

View TommyZG's full-sized avatar

Tomislav TommyZG

View GitHub Profile
@TommyZG
TommyZG / replaceText.js
Created October 16, 2023 08:33
Function to replace words/substrings in text, multiple lookups possible
// Function to replace substrings
function replaceText(input) {
// Define a map of substrings to their replacements
const dictionary = {
'fren': 'friend',
'ngmi': 'wagmi',
'rekt': 'screwed',
'rug': 'sbf'
};
@TommyZG
TommyZG / oldRightClick.txt
Created December 12, 2022 11:12
Command to revert to old right-click menu (context menu) in Windows 11
Open Command Prompt (cmd.exe)
In the terminal window, type:
reg.exe add "HKCU\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32" /f /ve
Restart Windows Explorer or the whole computer.
@TommyZG
TommyZG / jquery.fadeInOut.js
Created February 4, 2018 14:56
fadeIn and fadeOut with jQuery
// fadeIn
$('.selection').css({opacity: 0.0, visibility: "visible"}).animate({opacity: 1.0});
// fadeOut
$('.selection').css({opacity: 1.0, visibility: "visible"}).animate({opacity: 0});
@TommyZG
TommyZG / jquery.promise.js
Last active December 16, 2019 20:54
Example of jQuery Promise/Deferred usage
$(document).ready(function() {
getSomething().done(function() {
$("#success-alert").show();
}).fail(function() {
$("#fail-alert").show();
});
});
@TommyZG
TommyZG / git.sh
Last active October 30, 2022 17:19
Push existing project to Bitbucket
# Create repo @BitBucket
# cd /path/to/local/folder
git init
git add .
git remote add origin https://username@bitbucket.org/username/repo.git
git commit -m "Initial"
git push -u origin master
@TommyZG
TommyZG / artisan.sh
Last active November 19, 2017 15:26
Laravel 5.5 commands reference
php artisan make:migration create_users_table --create=users
php artisan migrate
# To rollback the latest migration operation, you may use the rollback command. This command rolls back the last "batch" of migrations, which may include multiple migration files:
php artisan migrate:rollback
#The migrate:reset command will roll back all of your application's migrations:
php artisan migrate:reset
//Initialize your project using npm init (in project folder) and create a directory called src
//Install babel dependencies by running
npm install babel-cli -D
npm install babel-preset-env -D
//Create a .babelrc file inside your project and add the following code inside it:
{
"presets": ["env"]
}
//Add the following script to your scripts object in package.json:
"build": "babel src -d lib"
class HospitalEmployee {
constructor(name) {
this._name = name;
this._remainingVacationDays = 20;
}
static generatePassword(){
return Math.floor(Math.random()*10000);
}
@TommyZG
TommyZG / class.js
Last active November 12, 2017 10:52
//declare class
class Surgeon {
//define constructor method - things that will be done on instantiation ('new')
constructor(name, department) { //when 'new-ing' instance of this class, expect 'name' and 'department' arguments
//we use underscore to define properties that aren't supposed to be acccessed directly
this._name = name;
this._department = department;
this._remainingVacationDays = 20;
}
//getter method - name as the property, but without underscore. This will be called with object.name
let person = {
_name: 'Lu Xun',
_age: 137,
set age(newAge) {
if (typeof newAge === 'number') {
this._age = newAge;
} else {
return 'Invalid input'
}
},