Skip to content

Instantly share code, notes, and snippets.

View houming818's full-sized avatar

houming818 houming818

View GitHub Profile
@houming818
houming818 / cVim.conf
Last active August 26, 2017 06:27
cVim.conf
" Settings
let barposition = "bottom"
set noautofocus
let searchengine instapaper = "https://www.instapaper.com/search?q=%s"
let searchengine pinboard = "https://www.pinboard.in/search/u:ironfish?query=%s"
let completionengines = ["google", "amazon", "instapaper", "pinboard"]
@houming818
houming818 / view.py
Created August 13, 2017 13:36
a dynamic view set for generating a restful API by django rest framework
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from __future__ import print_function
from django.conf import settings
from django_mysql.models import fields
from rest_framework.compat import is_authenticated
from rest_framework.filters import DjangoObjectPermissionsFilter
from rest_framework.metadata import SimpleMetadata
from rest_framework.permissions import DjangoObjectPermissions
@houming818
houming818 / models.py
Created August 9, 2017 03:23
add ManyToMany field in serializer of django rest_framework.
class LvsHostSerializer(HyperlinkedModelSerializer):
ipaddress = LvsIpaddressSerializer(read_only=True, many=True)
class Meta:
model = LvsHost
fields = '__all__'
class LvsClusterSerializer(HyperlinkedModelSerializer):
hosts = LvsHostSerializer(many=True)
@houming818
houming818 / controller.js
Last active August 7, 2017 12:03
angluarjs dynamic states example
angular.module('MetronicApp').controller('LvsGroupsController', function($model, $scope, localStorageService, $rootScope, $http, $timeout, runtimeStates, $state) {
runtimeStates.addState('lvs', {
name: 'lvs',
url: '/lvs',
data: {pageTitle: 'Lvs中心'},
templateUrl: '/static/views/lvs/main.html',
resolve: {
deps: ['$ocLazyLoad', function($ocLazyLoad) {
return $ocLazyLoad.load({
name: 'MetronicApp',
@houming818
houming818 / controller.js
Created August 7, 2017 12:01
angluarjs dynamic states example
angular.module('MetronicApp').controller('LvsGroupsController', function($model, $scope, localStorageService, $rootScope, $http, $timeout, runtimeStates, $state) {
runtimeStates.addState('lvs', {
name: 'lvs',
url: '/lvs',
data: {pageTitle: 'Lvs中心'},
templateUrl: '/static/views/lvs/main.html',
resolve: {
deps: ['$ocLazyLoad', function($ocLazyLoad) {
return $ocLazyLoad.load({
name: 'MetronicApp',
@houming818
houming818 / controller.js
Created August 7, 2017 12:01
angluarjs dynamic states example
angular.module('MetronicApp').controller('LvsGroupsController', function($model, $scope, localStorageService, $rootScope, $http, $timeout, runtimeStates, $state) {
runtimeStates.addState('lvs', {
name: 'lvs',
url: '/lvs',
data: {pageTitle: 'Lvs中心'},
templateUrl: '/static/views/lvs/main.html',
resolve: {
deps: ['$ocLazyLoad', function($ocLazyLoad) {
return $ocLazyLoad.load({
name: 'MetronicApp',
@houming818
houming818 / controller.js
Created August 7, 2017 12:01
angluarjs dynamic states example
angular.module('MetronicApp').controller('LvsGroupsController', function($model, $scope, localStorageService, $rootScope, $http, $timeout, runtimeStates, $state) {
runtimeStates.addState('lvs', {
name: 'lvs',
url: '/lvs',
data: {pageTitle: 'Lvs中心'},
templateUrl: '/static/views/lvs/main.html',
resolve: {
deps: ['$ocLazyLoad', function($ocLazyLoad) {
return $ocLazyLoad.load({
name: 'MetronicApp',
@houming818
houming818 / controller.js
Created August 7, 2017 12:00
angluarjs dynamic states example
angular.module('MetronicApp').controller('LvsGroupsController', function($model, $scope, localStorageService, $rootScope, $http, $timeout, runtimeStates, $state) {
runtimeStates.addState('lvs', {
name: 'lvs',
url: '/lvs',
data: {pageTitle: 'Lvs中心'},
templateUrl: '/static/views/lvs/main.html',
resolve: {
deps: ['$ocLazyLoad', function($ocLazyLoad) {
return $ocLazyLoad.load({
name: 'MetronicApp',
@houming818
houming818 / models.py
Last active August 5, 2017 08:09
JournalMixin for django Model
class JournalMixin(object):
def __init__(self, *args, **kwargs):
super(JournalMixin, self).__init__(*args, **kwargs)
logger.error('__Init__ save journal')
old_save = getattr(self, 'save', None)
if old_save is not None:
def new_save(self, *args, **kwargs):
logger.error('new save journal')
try:
old_save.im_func(self, *args, **kwargs)
@houming818
houming818 / .sls
Created July 17, 2017 06:18
write a salt sls file in pure python.
#!py
import salt.utils
import sys
def _sub_tail(host, port, filename):
import subprocess