Skip to content

Instantly share code, notes, and snippets.

View Regis011's full-sized avatar
:octocat:

Vladimir Rancic Regis011

:octocat:
View GitHub Profile
@Regis011
Regis011 / git-overwrite-branch.sh
Created October 14, 2023 14:19 — forked from ummahusla/git-overwrite-branch.sh
Git overwrite branch with another branch
# overwrite master with contents of feature branch (feature > master)
git checkout feature # source name
git merge -s ours master # target name
git checkout master # target name
git merge feature # source name
@Regis011
Regis011 / Split Swedish address
Created June 4, 2021 13:16
JavaScript when you can split Swedish Address to street name and street number and check if has apartment number inside
const addressSpliter = streetNameAndNumber => {
let streetName = "";
let streetNumber = "";
let splitString = streetNameAndNumber.split(" ");
splitString.forEach(element => {
//console.log("%d: %s", index, element);
const match1 = "[\\p{L}-]+";
@Regis011
Regis011 / Code Maker Javascript
Created September 29, 2020 08:14
This is javascript code maker for unique kay or id for your app
codeMaker(length) {
var result = '';
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~';
var charactersLength = characters.length;
for ( var i = 0; i < length; i++ ) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
}
return result;
}
@Regis011
Regis011 / Deploy script instruction
Last active September 17, 2020 06:51 — forked from francoisromain/project-create.sh
A bash script to create a Git post-receive hook to deploy after a Git push
Git is a great tool for version control, but not only. It can also simplify the deployment process, thanks to Git Hooks.
Three steps to configure the deployment process:
Image for post
1. Create an empty Git repo on the server
2. Write a Git Hook to deploy the code
3. Deploy from the local computer
tl;dr
On the remote server:
# Copy the 'project-create.sh' bash script https://gist.github.com/francoisromain/58cabf43c2977e48ef0804848dee46c3
# Then create a new project
@Regis011
Regis011 / git-deployment.md
Created September 17, 2020 06:44 — forked from noelboss/git-deployment.md
Simple automated GIT Deployment using Hooks

Simple automated GIT Deployment using GIT Hooks

Here are the simple steps needed to create a deployment from your local GIT repository to a server based on this in-depth tutorial.

How it works

You are developing in a working-copy on your local machine, lets say on the master branch. Most of the time, people would push code to a remote server like github.com or gitlab.com and pull or export it to a production server. Or you use a service like deepl.io to act upon a Web-Hook that's triggered that service.

@Regis011
Regis011 / gist:80b464113be66ae4c643dc9a0cc2ebbc
Created November 15, 2018 15:47
Laravel - search controller function for multiple keywords and long text in form query. Eloquent search query filters.
public function search(Request $request)
{
$res = (new BestCategory)->newQuery();
$q = $request->q;
$q = explode(' ', $q);
$res->where('title', 'like', '%'.$q[0].'%')->orWhere('description', 'like', '%'.$q[0].'%');
@Regis011
Regis011 / loopin add_action hook in the wordpress with acf pro
Last active November 17, 2017 07:52
loop add_action hook in the wordpress with acf pro
if( have_rows('my_add_widget', 'my_options') ): $i = 0;
while ( have_rows('my_add_widget', 'my_options') ) : the_row(); $i++;
add_action('wp_dashboard_setup', function () use($i){
global $wp_meta_boxes;
wp_add_dashboard_widget('custom_help_widget' . $i, 'Theme Support' . $i, function() use($i){
?>
<h1><?php the_field('test', 'my_options'); ?><?php echo $i ?></h1>
<p>Welcome to Custom Blog Theme! Need help? Contact the developer
@Regis011
Regis011 / Customize admon color scheme Wordpress
Last active November 17, 2017 07:52
Customize admin color scheme - Wordpress, wp-admin, admin, developer
<?php
function my_admin_color_schemes() {
$theme_dir = get_stylesheet_directory_uri();
// My color
wp_admin_css_color( 'my_color', __( 'My Color' ),
$theme_dir . '/stylesheets/admin-colors/my_puth/colors.css',
array('#222', '#333', '#f3962b', '#f9bf54')
@Regis011
Regis011 / Admin bar trycks wordpress - add links -> menus to the admin bar
Created November 11, 2016 23:55
Admin bar trycks wordpress - add links -> menus to the admin bar
@Regis011
Regis011 / Moving a Wordpress site to other domain names
Created November 11, 2016 23:52
Moving a Wordpress site to other domain names
//SQL:
UPDATE wp_options SET option_value = replace(option_value, 'http://old.com', 'http://new.com');
UPDATE wp_posts SET guid = replace(guid, 'http://old.com','http://new.com');
UPDATE wp_posts SET post_content = replace(post_content, 'http://old.com', 'http://new.com');