Skip to content

Instantly share code, notes, and snippets.

View 1c7's full-sized avatar

ZhengCheng 1c7

View GitHub Profile
# -*- coding: utf-8 -*-
import os
import sys
import pysubs
try:
print (sys.argv[1])
print()
file_full_path = sys.argv[1]
except:
@1c7
1c7 / gist:15631350e08e80f39772
Created May 3, 2014 15:00
output_some_thing_to_file-1c7.cpp
#include <fstream>
#include <iostream>
using namespace std;
int main(){
cout << "hahahahahahahah" << endl;
ofstream fout("output.txt");
fout << "nice" << endl;
fout << "good" << endl;
@1c7
1c7 / read-1c7.cpp
Last active August 29, 2015 14:00
read-1c7.cpp
#include <fstream>
#include <iostream>
#include <string>
// read some file for pratice
using namespace std;
int main(){
ifstream fin("read.txt");
@1c7
1c7 / gist:d27e636acf4f8ba73de2
Created December 16, 2014 07:24
set <input type=date> today
var e = document.getElementById('<input type=date>');
set_today(e);
function set_today(inputElement){
// document:
// var recommend_date = document.getElementById('<input type='date'> id');
// set_today(recommend_date);
var dateobj = new Date();
var year = dateobj.getFullYear();
var month = dateobj.getMonth() + 1;
@1c7
1c7 / gist:d2a170335b2ed7e44b45
Created December 31, 2014 05:43
change URL
function addURLParameter(paramName, paramValue, URL){
var url_list = URL.split('?');
var haveParameter = false;
// if there no parameter, return false;
if(url_list[1]){
haveParameter = true;
}
@1c7
1c7 / gist:5790812
Last active December 18, 2015 13:38
(文章) Windows下快速进入当前目录的命令行
写一个 *.bat
名字你随意, 比如aaa.bat
里面写上:
@echo off
cmd.exe
双击这个bat. 就可以进入当前目录的命令行.
@1c7
1c7 / gist:6103364
Last active December 20, 2015 08:49
(Python) 输出当前目录下 index.html 文件的路径
import os
import sys
path = os.path.join(os.path.dirname(sys.argv[0]), 'index.html')
print path
@1c7
1c7 / gist:6103727
Created July 29, 2013 11:31
(Python) 获得文件的后缀
file_path = r'D:\Everything\Everything.exe'
l = str(file_path).split('.')
extension = l[len(l)-1]
print (extension)
# exe
@1c7
1c7 / gist:6246893
Created August 16, 2013 02:56
(Python) 最短的写文件代码
out = open('a.txt', 'w')
print('Hello Earth!', file=out)
out.close()
# 在 Python3.3.0 能成功运行
# 2.7不行
# 这会创建一个叫做a.txt的文件, 内容是'Hello Earth!', 屏幕上并不会有任何输出
@1c7
1c7 / gist:8156368
Created December 28, 2013 05:29
传入多个参数时, 把多个参数都输出. 传1个参数时什么都不做.
import sys
if len(sys.argv) > 2:
for x in sys.argv[1:]:
print (x)
input()