Skip to content

Instantly share code, notes, and snippets.

View xgenvn's full-sized avatar

TuNA xgenvn

View GitHub Profile
@xgenvn
xgenvn / models.py
Created March 24, 2017 10:29 — forked from alanhamlett/models.py
django model manager example
from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin, BaseUserManager
from django.db import models, transaction
from django.utils import timezone
class Manager(models.Manager):
""" Use this class to define custom methods on models.
"""
def get_query_set(self):
@xgenvn
xgenvn / targets.xml
Created March 30, 2017 12:34 — forked from tylerjromeo/targets.xml
MsBuild targets to edit android build version in android manifest and iOS build version in info.plist
<Target Name="BeforeBuild" Condition=" $(SetVersion) == true ">
<XmlPoke XmlInputPath="Info.plist" Query="//dict/key[. = 'CFBundleVersion']/following-sibling::string[1]" Value="$(BuildNumber)" />
<XmlPoke XmlInputPath="Info.plist" Query="//dict/key[. = 'CFBundleShortVersionString']/following-sibling::string[1]" Value="1.0.$(BuildNumber)" />
</Target>
<Target Name="BeforeBuild" Condition=" $(SetVersion) == true ">
<XmlPoke XmlInputPath="Properties\AndroidManifest.xml" Namespaces="&lt;Namespace Prefix='android' Uri='http://schemas.android.com/apk/res/android' /&gt;" Query="manifest/@android:versionCode" Value="$(BuildNumber)" />
<XmlPoke XmlInputPath="Properties\AndroidManifest.xml" Namespaces="&lt;Namespace Prefix='android' Uri='http://schemas.android.com/apk/res/android' /&gt;" Query="manifest/@android:versionName" Value="1.0.$(BuildNumber)" />
</Target>
@xgenvn
xgenvn / ObservableDictionary.cs
Created April 21, 2017 08:58 — forked from kzu/ObservableDictionary.cs
An ObservableDictionary<TKey, TValue>
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Diagnostics;
using System.Dynamic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Update 7 Oct 2010:
# - This example does *not* appear to work with Chrome >=6.0. Apparently,
# the WebSocket protocol implementation in the cramp gem does not work
# well with Chrome's (newer) WebSocket implementation.
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby
@xgenvn
xgenvn / cs.py
Created May 31, 2017 06:38 — forked from myano/cs.py
Quick example of ncurses in Python!
#!/usr/bin/env python
import curses
import curses.textpad
import time
stdscr = curses.initscr()
#curses.noecho()
#curses.echo()
@xgenvn
xgenvn / android_instructions.md
Created August 7, 2017 02:57 — forked from patrickhammond/android_instructions.md
Easily setup an Android development environment on a Mac

Here is a high level overview for what you need to do to get most of an Android environment setup and maintained.

Prerequisites (for Homebrew at a minimum, lots of other tools need these too):

  • XCode is installed (via the App Store)
  • XCode command line tools are installed (xcode-select --install will prompt up a dialog)
  • Java

Install Homebrew:

ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"

@xgenvn
xgenvn / web_ui_elements_naming_convention.md
Last active August 8, 2017 01:14 — forked from hosuaby/web_ui_elements_naming_convention.md
Simple convention for naming GUI elements of Web applications

Simple convention for naming GUI elements of Web applications

Ids or names of elements (primitives or complexes) must be written in Camel Case and must to be as short as possible. All id or name must to start with one of the defined element type prefixes.

Element type prefixes

All element ids or names must use Hungarian notation to incorporate the type of element. Prefixes are used to indicate the semantic type of the element, rather than it's underlining implementation. It means that the element of GUI with button look & feel must prefixed as btn, regardless of how it is implemented, with tag <button> or with tag <a>.
Prefixes are lowercase strings of 2, 3 or 4 characters. Here a complete list of authorised prefixes:

  • btn - the button or a link with a button look & feel
@xgenvn
xgenvn / Free O'Reilly Books.md
Created August 19, 2017 15:16 — forked from augbog/Free O'Reilly Books.md
Free O'Reilly Books

Free O'Reilly books and convenient script to just download them.

Thanks /u/FallenAege/ and /u/ShPavel/ from this Reddit post

How to use:

  1. Take the download.sh file and put it into a directory where you want the files to be saved.
  2. cd into the directory and make sure that it has executable permissions (chmod +x download.sh should do it)
  3. Run ./download.sh and wee there it goes. Also if you do not want all the files, just simply comment the ones you do not want.
@xgenvn
xgenvn / backup.ps1
Created August 26, 2017 12:36
Powershell Script To Back Up MySQL
$DateString = (Get-Date -Format "yyyyMMdd")
$Databases = @("wp_database_1", "wp_database_2", "wp_database_3")
foreach ($databaseName in $Databases)
{
$BackupCommand = '"C:\Program Files\MySQL\MySQL Server 5.7\bin\mysqldump.exe"
--defaults-file=credentials.ini --host=localhost
--protocol=tcp --port=1234 --default-character-set=utf8 --add-drop-database
--add-drop-table --result-file="Z:\Backups\Database\MySQL\' +
$databaseName + '\bak_' + $DateString + '.sql" --skip-triggers "' +
@xgenvn
xgenvn / get_date.bat
Last active August 26, 2017 12:53
Get Date from DOS
@echo on
:: GENERATE UNIQUE
for /f "skip=1 tokens=2-4 delims=(-)" %%a in ('"echo.|date"') do (
for /f "tokens=1-3 delims=/.- " %%A in ("%date:* =%") do (
set %%a=%%A&set %%b=%%B&set %%c=%%C))
set /a "yy=10000%yy% %%10000,mm=100%mm% %% 100,dd=100%dd% %% 100"
for /f "tokens=1-4 delims=:. " %%A in ("%time: =0%") do @set UNIQUE=%yy%%mm%%dd%%%A%%B%%C%%D