Skip to content

Instantly share code, notes, and snippets.

@allyusd
allyusd / linux-auto-build-qt-project-when-file-modify.sh
Last active January 13, 2022 19:22
arch linux auto build qt project when file modify use inotify-tools
#!/bin/sh
while true
do
inotifywait -e modify -r .
qmake -project
qmake
make
done
@allyusd
allyusd / sql.cpp
Last active February 20, 2022 18:49
Qt PostgreSQL Example
QSqlDatabase db = QSqlDatabase::addDatabase("QPSQL");
db.setHostName("127.0.0.1");
db.setDatabaseName("FirstDB");
db.setUserName("demo");
db.setPassword("password");
bool ok = db.open();
if (ok)
{
QSqlQuery query("SELECT \"SID\", \"Account\", \"CreateDate\", \"LoginTimes\" FROM \"Account\"");
@allyusd
allyusd / AngularJS - ui-router - main.html
Created August 7, 2014 08:25
AngularJS - ui-router - main.html
<ul class="menu">
<li><a ui-sref="main.view1">view1</a></li>
<li><a ui-sref="main.view2">view2</a></li>
</ul>
<div ui-view></div>
<div>Angular seed app: v<span app-version></span></div>
@allyusd
allyusd / AngularJS - ui-router - index.html
Created August 7, 2014 08:24
AngularJS - ui-router - index.html
<div ui-view></div>
@allyusd
allyusd / AngularJS - ui-router - app.js config
Created August 7, 2014 08:23
AngularJS - ui-router - app.js config
config(['$stateProvider', '$urlRouterProvider', function($stateProvider, $urlRouterProvider) {
//
// For any unmatched url, redirect to
$urlRouterProvider.otherwise("/main");
//
// Now set up the states
$stateProvider
.state('main', {
url: "/main",
templateUrl: "partials/main.html"
@allyusd
allyusd / AngularJS - ngRoute - index.html
Created August 7, 2014 08:22
AngularJS - ngRoute - index.html
<ul class="menu">
<li><a href="#/view1">view1</a></li>
<li><a href="#/view2">view2</a></li>
</ul>
<div ng-view></div>
@allyusd
allyusd / AngularJS - ngRoute - app.js config
Created August 7, 2014 08:21
AngularJS - ngRoute - app.js config
config(['$routeProvider', function($routeProvider) {
$routeProvider.when('/view1', {templateUrl: 'partials/partial1.html', controller: 'MyCtrl1'});
$routeProvider.when('/view2', {templateUrl: 'partials/partial2.html', controller: 'MyCtrl2'});
$routeProvider.otherwise({redirectTo: '/view1'});
}])
@allyusd
allyusd / Book.cs
Last active October 1, 2015 06:24
C# Serialization
[Serializable]
/// <summary> Book Class </summary>
internal class Book
{
/// <summary> Book Name </summary>
public string Name { get; set; }
/// <summary> Book ID </summary>
public int Id { get; set; }