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
#!/usr/bin/env python
import argparse, getpass
class Password(argparse.Action):
def __call__(self, parser, namespace, values, option_string):
if values is None:
values = getpass.getpass()
setattr(namespace, self.dest, values)
@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 / vietnam-mobile-phone-classify.php
Created February 19, 2016 08:54
Vietnam mobile phone classify
<?php
$phones = [
"0987654321",
"0912345678",
"01234567890",
"01650930293",
"0992938392",
"01882938493",
"0902938292",
@namnv609
namnv609 / ws-with-apache2-proxy.conf
Last active February 12, 2019 21:13
ActionCable WebSocket with Apache2 proxy
<VirtualHost *:80 *:443>
# Domain
ServerName servername.domain
SSLEngine On
SSLProxyEngine On
# Path to SSL CRT file
SSLCertificateFile /etc/apache2/ssl/apache.crt
# Path to SSL KEY file
SSLCertificateKeyFile /etc/apache2/ssl/apache.key
@namnv609
namnv609 / ws-with-nginx-proxy
Created June 24, 2016 04:32
ActionCable WebSocket with NginX proxy
server {
listen 80;
listen 443 ssl;
server_name servername.domain;
ssl on;
ssl_certificate /etc/apache2/ssl/apache.crt;
ssl_certificate_key /etc/apache2/ssl/apache.key;
ssl_session_timeout 5m;
ssl_protocols SSLv2 SSLv3 TLSv1;
@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