Skip to content

Instantly share code, notes, and snippets.

View leopard627's full-sized avatar
🦖
Working from home

Leopard627 leopard627

🦖
Working from home
View GitHub Profile
@leopard627
leopard627 / tmux-cheatsheet.markdown
Created March 20, 2017 14:05 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
import stripe
stripe.api_key = 'tGN0bIwXnHdwOa85VABjPdSn8nWY7G7I'
print "Attempting charge..."
resp = stripe.Charge.create(
amount=200,
currency='usd',
card={
@leopard627
leopard627 / test_models.py
Last active May 18, 2017 06:54
image_mocking.py
def using_mock():
import mock
from django.core.files import File
file_mock = mock.MagicMock(spec=File, name='FileMock')
def using_tempfile():
import tempfile
# 보면 이런식으로 여러줄의 라인을 한 줄로 만들 수 있습니다.
# style 1
current_id = return_response.data["id"]
current_banking = LOLOBanking.objects.get(id=current_id)
current_banking.related_id = withdraw_account_id
current_banking.withdraw_type = withdraw_type
current_banking.bank_type = wa.bank_type
current_banking.save
@leopard627
leopard627 / stupid_write.py
Last active May 22, 2017 14:33
마지막 테일값에 쓰레기값이 붙습니다만 . . .
a = ['Hello', 'Sydney', 'I', 'Am']
b = [1, 2, 3, -1212.022, 5523, 232441, 1000]
# way 1 방법1
with open("foo.txt", "w") as f:
map(lambda var: f.write(str(var)) if var == b[-1:][0] else f.write(str(var) + " "), b)
# way 2 방법2
with open("foo.txt", "w") as f:
@leopard627
leopard627 / mock_example1.py
Created May 24, 2017 13:41
mock_example_python2.7.xx
import unittest
from os import urandom
import mock
def simple_urandom(length):
return 'f' * length
class TestRandom(unittest.TestCase):
@leopard627
leopard627 / main.py
Last active May 24, 2017 16:02
mocking_master_part1 // python2.7.x 에서 mock.patch를 사용해서 테스트를 유연하게 진행시키는 부분입니다.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
from os import urandom
import mock
import unittest
import pytest
from fots import abc_urandom
@leopard627
leopard627 / mock_example2.py
Last active May 25, 2017 08:53
Mocking Functions Using Context Managers
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import unittest
import mock
import pytest
from fots import abc_urandom, my_random
@leopard627
leopard627 / main.go
Created June 21, 2017 04:46
go orm expl
package main
import (
"beegoorm/models"
"fmt"
"github.com/astaxie/beego"
"github.com/astaxie/beego/orm"
_ "beegoorm/routers"
_ "github.com/go-sql-driver/mysql"
@leopard627
leopard627 / session.go
Created July 5, 2017 14:02
beego session
import (
"github.com/astaxie/beego"
)
func (c *AdminController) Logindo() {
username := c.GetString("username")
c.SetSession("Adminname", username) //设置Session
adminName := c.GetSession("Adminname") //读取Session
c.DelSession("Adminname") //删除Session
c.TplNames = "admin/login.html"
}