To change the data type of column in table, use this:
ALTER TABLE channels ALTER COLUMN settings TYPE jsonb USING settings::jsonb;
– Senior Fullstack Web Engineer
To change the data type of column in table, use this:
ALTER TABLE channels ALTER COLUMN settings TYPE jsonb USING settings::jsonb;
If we have this code from a random Gulp file:
babelify : require('babelify'),
browserify : require('browserify'),
buffer : require('vinyl-buffer'),
changed : require('gulp-changed'),
collapse : require('bundle-collapser/plugin'),
concat : require('gulp-concat'),
cssnano : require('gulp-cssnano'),
declare : require('gulp-declare'),
gulp : require('gulp'),
gulp_handlebars : require('gulp-handlebars'),
gutil : require('gulp-util'),
htmlclean : require('gulp-htmlclean'),
jsdoc : require('gulp-jsdoc3'),
merge : require('merge-stream'),
path : require('path'),
rename : require('gulp-rename'),
sass : require('gulp-sass'),
source : require('vinyl-source-stream'),
sourcemaps : require('gulp-sourcemaps'),
transform : require('vinyl-transform'),
uglify : require('gulp-uglify'),
watchify : require('watchify'),
wrap : require('gulp-wrap'),
And quickly want to run an npm install using these modules.
We can run a search and replace with Sublime Text using this formular:
Find:
(.*) : require\('(.*)'\),
/invisible new line character here
Replace:
$2 /invisible space character here
This will find:
<any number of any character> : require('<any number of any character>'),
And replace it with the content of the second group (.*) represented by:
$2
You can now copy the whole line, and type:
npm i (and paste the clipboard content here)
into the terminal.
Voila!
A comma separated string to console.log();
If you have this:
, type, name, declaration, options, callback, internal, useRequired, skipEmit, uptodateName, next, packageName
Then find this:
, ([^,]+)
Replace with:
console.log( "$1", $1 );
This:
, type, name, declaration, options, callback, internal, useRequired, skipEmit, uptodateName, next, packageName
becomes this:
console.log( "type", type ); console.log( "name", name ); console.log( "declaration", declaration ); console.log( "options", options ); console.log( "callback", callback ); console.log( "internal", internal ); console.log( "useRequired", useRequired ); console.log( "skipEmit", skipEmit ); console.log( "uptodateName", uptodateName ); console.log( "next", next ); console.log( "packageName", packageName );
Install with Homebrew:
$ brew install postgresql
Start postgresql as a service
$ brew services start postgresql
Enter Queries using psql:
$ psql postgres
Create database:
$ CREATE DATABASE database_name
Add table:
$ ALTER DATABASE database_name
(press enter, and do not end with a semi-colon. This will make it possible to enter multiple lines).
$ ADD COLUMN id integer;
Set id as primary key:
$ ALTER TABLE table_name
(press return)
$ ADD PRIMARY KEY (column_name);
class Cookie {
constructor () {}
set( cname, cvalue, exdays ) {
var d = new Date();
d.setTime( d.getTime() + ( exdays*24*60*60*1000 ) );
var expires = "expires="+ d.toUTCString();
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}
get( cname ) {
var name = cname + "=";
var decodedCookie = decodeURIComponent( document.cookie );
var ca = decodedCookie.split( ';' );
for( var i = 0; i < ca.length; i++ ) {
var c = ca[ i ];
while ( c.charAt( 0 ) == ' ' ) {
c = c.substring( 1 );
}
if ( c.indexOf( name ) == 0 ) {
return c.substring( name.length, c.length );
}
}
return "";
}
}
export default Cookie;
Run:
git clean -n(d)
To preview what will be removed.
Run:
git clean -fd
To force remove files and directories.
var gulp = require('gulp'),
uglify = require('gulp-uglify'),
rename = require('gulp-rename'),
concat = require('gulp-concat'),
handlebars = require('gulp-handlebars'),
wrap = require('gulp-wrap'),
path = require('path'),
htmlclean = require('gulp-htmlclean'),
merge = require('merge-stream'),
declare = require('gulp-declare'),
source = require('vinyl-source-buffer'),
/**
* Compile handlebars templates
*/
gulp.task('templates', function () {
// Assume all partials start with an underscore
// You could also put them in a folder such as source/templates/partials/*.hbs
var partials = gulp.src( partials_source )
.pipe( htmlclean() )
.pipe( handlebars())
.pipe( wrap('Handlebars.registerPartial(<%= processPartialName(file.relative) %>, Handlebars.template(<%= contents %>));', {}, {
imports: {
processPartialName: function(fileName) {
// Strip the extension and the underscore
// Escape the output with JSON.stringify
return JSON.stringify(path.basename(fileName, '.js').substr(1));
}
}
}));
var templates = gulp.src( templates_source )
.pipe( htmlclean() )
.pipe( handlebars() )
.pipe( wrap('Handlebars.template(<%= contents %>)') )
.pipe( declare({
namespace : 'Publish.templates',
noRedeclare : true
}));
return merge(partials, templates)
.pipe( uglify() )
.pipe( concat( 'publish.templates.js' ) )
.pipe( rename( { suffix : '.min' } ) )
.pipe( gulp.dest('./publish/assets/js') );
});
If you have this:
const dummy_data = {
toplinks : ['Shop','Publish','Read'],
is_staff : true,
latam : false,
user : {
is_authenticated : true,
first_name : "John",
last_name : "Doe"
},
currentLanguage : 'DA',
language : [
'DA',
'EN'
]
};
var template = Publish.templates.navigation,
output = template( dummy_data );
$('body').prepend( output );
Do this in the main template:
{{> toplinks toplinks=this.toplinks staff=this.is_staff}}
And this in the partial:
{{#each toplinks}}
<a href="{{this}}" target="_blank" class="nav-btn">{{this}}</a>
{{/each}}
{{#if staff}}
<a href="#" target="_top" class="nav-btn">Admin</a>
{{/if}}
For .htaccess to redirect to subfolder, add and .htaccess file to the root with the following content:
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_URI} !^/path/to/folder/
# Rewrite all those to insert /path_to_folder_from_root
RewriteRule ^(.*)$ /path/to/folder/$1 [L]
Run this line for Sublime Text 2:
ln -s /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl /usr/local/bin/subl2
Use like:
subl2 .
Run this line for Sublime Text 3:
ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/local/bin/subl3
Use like:
subl3 .
Put the following in your .bash_profile
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1="\u@\h \W\[\033[32m\]\$(parse_git_branch)\[\033[00m\] "