Skip to content

Instantly share code, notes, and snippets.

View xros's full-sized avatar
🎯
Focusing

Songhua Liu xros

🎯
Focusing
View GitHub Profile
@xros
xros / watcher.py
Created July 1, 2016 21:02 — forked from d1b/watcher.py
#!/usr/bin/python
__version__="0.0.1"
__author__="david"
__email__="[email protected]"
import argparse
import csv
import json
from multiprocessing import Process
import netaddr
@xros
xros / Android Studio .gitignore
Created August 11, 2016 13:18 — forked from iainconnor/Android Studio .gitignore
A .gitignore for use in Android Studio
# Built application files
/*/build/
# Crashlytics configuations
com_crashlytics_export_strings.xml
# Local configuration file (sdk path, etc)
local.properties
# Gradle generated files
server {
listen 80;
server_name www.example.com;
rewrite ^ http://example.com$request_uri? permanent; #301 redirect
}
server {
listen 80;
server_name example.com;
@xros
xros / steam_console_params.txt
Created January 24, 2018 00:50 — forked from davispuh/steam_console_params.txt
Steam client parameters, consoles commands and variables
-480p - Run tenfoot in 480p rather than 1080p
-720p - Run tenfoot in 720p rather than 1080p
-accountrecovery - Perform account recovery
-all_languages - show longest loc string from any language
-bigpicture - Start in Steam Big Picture mode
-cafeapplaunch - Launch apps in a cyber cafe context
-candidates - Show libjingle candidates for local connection as they are processed
-ccsyntax - Spew details about the localized strings we load
-community - Set the community URL
-complete_install_via_http - Run installation completion over HTTP by default
# retrieve webelement
input = driver.find_element_by_xpath("//*[@name='fieldname']")
# set attribute from js script referencing webelement found in python code
driver.execute_script("arguments[0].setAttribute('value', 'new value!')", input);
# or
driver.execute_script("arguments[0].setAttribute('value', arguments[1])", input, 'new value!');
# Code for File Upload
file_input = driver.find_element_by_id("uploadBtn")
file_input.send_keys("/absolute/path/to/file")
import 'dart:math';
/*
We can use abstract classes to define an interface that can be implemented by subclasses
Very powerful: decouples code that uses an interface from its implementation
printArea() doesn't need to know that Sqaure and Circle even exist.
only needs a Shape argument with an area property
*/
class Person {
const Person(this.name, this.age);
final String name;
final int age;
factory Person.fromJson(Map<String, Object> json) {
final name = json['name'];
final age = json['age'];
if (name == null) {
import 'dart:io';
/*
* An implementation of shopping cart and checkout in Dart
*
*/
class Product {
const Product({required this.id, required this.name, required this.price});
final int id;
final String name;
@xros
xros / main.dart
Last active December 26, 2021 14:51
.fromJson & .toJson example in Dart
// .fromJson , .toJson example in Dart
// .fromJson convert a Map Object to an Instance
// .toJson convert an Instance to a Map Object
class Person {
Person({required this.name, required this.age});
String name;
int age;
factory Person.fromJson(Map<String, Object> json) {
final name = json['name'];
@xros
xros / main.dart
Last active December 26, 2021 14:52
simple copyWith method in Dart
// simple copyWith method
class Credentials {
const Credentials({this.email = '', this.password = ''});
final String email;
final String password;
Credentials copyWith({String? email, String? password}) {
return Credentials(
email: email ?? this.email,
password: password ?? this.password,