Skip to content

Instantly share code, notes, and snippets.

View namnv609's full-sized avatar
🥰
Preparing for something new

NamNV609 namnv609

🥰
Preparing for something new
View GitHub Profile
controllers.controller('MainCtrl', function($scope, $location, Facebook, $rootScope, $http, $location, Upload, Auth, User, Question, Category, Serie, Record, Location, Popup, Process, Card, Question) {
$scope.$on('authLoaded', function() {
$scope.isExpert($scope.main.serieId);
$scope.isMember($scope.main.serieId);
});
$scope.loadAuth = function() {
Auth.load().success(function(data) {
$scope.main.user = data.user;
$scope.$broadcast("authLoaded");

MacOS

Build 3059

MD5: 59bab8f71f8c096cd3f72cd73851515d

Rename it to: Sublime Text

Make it executable with: chmod u+x Sublime\ Text

@namnv609
namnv609 / node.js
Created December 30, 2015 16:41 — forked from sirkitree/node.js
Parse a PHP file with Node.js and convert an array defined in the PHP script into a JSON object which the Node app can use.
var runner = require('child_process');
runner.exec(
'php -r \'include("settings.php"); print json_encode($databases);\'',
function (err, stdout, stderr) {
var connection = JSON.parse(stdout).default.default;
console.log(connection.database);
// result botdb
}
#!/bin/sh
### BEGIN INIT INFO
# Provides: <SCRIPT_NAME>
# Required-Start: $local_fs $network $named $time $syslog
# Required-Stop: $local_fs $network $named $time $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: Script to run asp.net 5 application in background
### END INIT INFO
@namnv609
namnv609 / php-datetime-range.php
Created February 18, 2016 13:43
Create datetime range with a date
<?php
$date = "2016-01-01";
$outputFormat = "d/m/Y H:i:s";
$startTime = strtotime(date($date));
$endTime = strtotime(sprintf("%s 23:59:59", $date));
$dateTimes = [];
while ($startTime < $endTime) {
$startTime += 60;
@namnv609
namnv609 / export-csv.rb
Created June 28, 2016 03:51
Example export CSV with CP932 in Ruby on Rails
require "csv"
class Admin::ExportsController < Admin::BaseAdminController
def index
admin = Admin.first
csv_string = CSV.generate do |csv|
csv << Admin.attribute_names
csv << admin.attributes.values
end
======= Prolbem =================================================================================================================
I have installed : ruby-2.0.0,postgres-9.2 , now in rails app when I execute:
rake db:create , command I get:
PG::InvalidParameterValue: ERROR: new encoding (UTF8) is incompatible with the encoding of the template database (SQL_ASCII)
HINT: Use the same encoding as in the template database, or use template0 as template.
: CREATE DATABASE "my_db_name" ENCODING = 'unicode'.......
bin/rake:16:in `load'
@namnv609
namnv609 / resumable-download.php
Created September 12, 2016 10:43 — forked from kosinix/resumable-download.php
PHP - resumable download
<?php
class ResumeDownload {
private $file;
private $name;
private $boundary;
private $delay = 0;
private $size = 0;
function __construct($file, $delay = 0) {
if (! is_file($file)) {
@namnv609
namnv609 / laravel-nginx
Created November 25, 2016 09:15
NginX and PHP7 with Laravel config
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root <Path to project folder>/public;
index index.php index.html index.htm;
server_name <Server name or IP address>;
location / {
@namnv609
namnv609 / pre-push
Created December 1, 2016 03:08
CI local for Git client
#!/usr/bin/env bash
redColor="\033[0;31m"
noColor="\033[0m"
function exitCodeToText() {
text="${redColor}NG${noColor}"
if [[ "$1" == "0" ]]; then
text="OK"
fi