Dump database:
$ pg_dump database_name > database_name.sql
Import database:
$ psql database_name < database_file.sql
– Senior Fullstack Web Engineer
Dump database:
$ pg_dump database_name > database_name.sql
Import database:
$ psql database_name < database_file.sql
To add a submodule:
Add submodule (another repo):
$ git submodule add <path-to-repo>
Commit and push changes.
When cloning the parent project, only empty submodule folders get pulled. To actually pull the submodules you need to initialize and update the modules.
To install a submodule:
$ git submodule init
$ git submodule update
You can do this in one go by adding –recurse-submodules.
$ git clone –recurse-submodules <path-to-repo>
If you forgot the –recurse-submodules when cloning, you can combine the ‘init’ and ‘update’ command by running:
$ git submodules update –init
And the foolproof way:
$ git submodules update –init –recursive
for f in **/*.ts; do mv “$f” “${f%.ts}.js”; done
# Step 1 # create main branch locally, taking the history from master git branch -m master main # Step 2 # push the new local main branch to the remote repo (GitHub) git push -u origin main # Step 3 # switch the current HEAD to the main branch git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/main # Step 4 # change the default branch on GitHub to main # https://docs.github.com/en/github/administering-a-repository/setting-the-default-branch # Step 5 # delete the master branch on the remote git push origin --delete master
This will keep the first instance of a duplicate:
sort for_db.txt | uniq > for_db_no_duplicates_2.txt
This will remove all duplicates (including the first occurence):
sort for_db.txt | uniq -u > for_db_no_duplicates_2.txt
Replace <PortNumber> with the port that is already in use
$ lsof -i :<PortNumber>
Find the PID in the result from above and replace <PID> with that.
$ kill -9 <PID>
$ cd into folder with files
Run the following command from the Terminal:
$ for f in *; do mv “$f” “`echo $f | tr “[:upper:]” “[:lower:]”`”; done
on run {input, parameters}
tell application "Terminal"
reopen
activate
end tell
end run
If you cannot connect to PostgreSQL, try this:
brew postgresql-upgrade-database
And restart PostgreSQL by running this:
brew services restart postgresql
Add this to your ‘functions.php’ file:
wp_localize_script( 'portfolio-application', 'my_ajax_object', array(
// URL to wp-admin/admin-ajax.php to process the request
'ajaxurl' => admin_url( 'admin-ajax.php' ),
// generate a nonce with a unique ID "myajax-post-comment-nonce"
// so that you can check it later when an AJAX request is sent
// 'security' => wp_create_nonce( 'my-special-string' )
));
function get_data() {
$the_posttype = $_GET['posttype'];
$args = array(
'numberposts' => -1, // -1 is for all
'post_type' => $the_posttype, // or 'post', 'page'
'orderby' => 'title', // or 'date', 'rand'
'order' => 'ASC', // or 'DESC'
//'category' => $category_id,
//'exclude' => get_the_ID()
// ...
// http://codex.wordpress.org/Template_Tags/get_posts#Usage
);
$cases = get_posts( $args );
header('Content-Type: application/json');
echo json_encode( $cases );
wp_die();
}
add_action('wp_ajax_get_cases', 'get_cases');
add_action('wp_ajax_nopriv_get_cases', 'get_cases');
Where ‘the-application’ is the enqueued script from where you make the $.ajax … or whatever call.
Add this to your javascript application (whatever file it may be ‘build’ into using a build process like gulp or what ever):
let config = {
action : 'get_data', // The metod in the function.php file to call
posttype : 'case' // Arbitrary data to pass to the call
};
$.ajax({
url : my_ajax_object.ajaxurl,
type: 'GET',
data : {
'action' : config.action,
'posttype' : config.posttype
}
}).done(function ( response ) {
// Handle response
}).fail(function ( err ) {
// Handle error
});