Skip to content

Instantly share code, notes, and snippets.

DROP TRIGGER IF EXISTS upd_user;

DELIMITER $$

CREATE TRIGGER upd_user BEFORE UPDATE ON `user`
FOR EACH ROW BEGIN
  IF (NEW.password IS NULL OR NEW.password = '') THEN
        SET NEW.password = OLD.password;
  ELSE

SET NEW.password = Password(NEW.Password);

Functional Programming with React

In JS Functions can represent data in your applications

const log = message=>console.log(message)

Since Functions are variables we can add them to objects

const obj = {
		message: "They can be added to objects like variables",
		log

Generate ssh key

$ ssh-keygen

Copy the public key to ubuntu server

cat ~/.ssh/id_rsa.pub | ssh username@remote_host "mkdir -p ~/.ssh && touch ~/.ssh/authorized_keys && chmod -R go= ~/.ssh && cat >> ~/.ssh/authorized_keys"
sudo curl -s https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
#The install command (composer require symfony/symfony)
#The current version (3.2.4)
#Create a directory on your server for this project:
sudo mkdir /var/www/html/symfony-test
cd /var/www/html/symfony-test
sudo vim composer.json
@sagarPakhrin
sagarPakhrin / installapache.sh
Last active June 30, 2019 09:10
Installing apache and mysql
#update
sudo apt update && sudo apt -y upgrade
#install apache
sudo apt install -y apache2
#Install php
sudo apt-get install -y php libapache2-mod-php
#install mysql
sudo apt install -y mysql-server
sudo mysql_secure_installation
sudo mysql -u root -p
@sagarPakhrin
sagarPakhrin / webstoemp-gulpfile.js
Created March 17, 2019 21:10 — forked from jeromecoupe/webstoemp-gulpfile.js
Gulp 4 sample gulpfile.js. For a full explanation, have a look at https://www.webstoemp.com/blog/switching-to-gulp4/
"use strict";
// Load plugins
const autoprefixer = require("autoprefixer");
const browsersync = require("browser-sync").create();
const cp = require("child_process");
const cssnano = require("cssnano");
const del = require("del");
const eslint = require("gulp-eslint");
const gulp = require("gulp");
@sagarPakhrin
sagarPakhrin / blag_model.py
Created March 17, 2019 16:42 — forked from x86ed/blag_model.py
Django blog model
import urllib2
import mimetypes
from django.conf import settings
from django.db import models
from django.contrib.auth.models import User
class Category(models.Model):
name = models.CharField(max_length=32)
class Meta:
#!/usr/bin/env python
"""Script that I keep in a Git repository along with my dotfiles. In the
repository, the files don't have the dot prefix so I can see them more easily.
Running the script symlinks all the files to ~/.<filename>, checking allowing
you to cancel if the file exists.
"""
import os
import glob