This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Data.SqlClient; | |
| //Step 1: Handshake with the database | |
| SqlConnection myConnection = new SqlConnection(connection string); | |
| myConnection.Open(); | |
| //Step2: Specify the command | |
| SqlCommand myCommand = myConnection.CreateCommand(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //No connection of Connection string creation | |
| //No DataAdapter configuration | |
| //Automatically generates an adapter specifically for working with OUR tables. | |
| //ex. | |
| CustomerDataSetTableAdapters.CustomersTableAdapter cta = new CustomerDataSetTableAdapter; | |
| CustomerDataSet ds = new CustomerDataSet(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sample_dict = {'Four': 4, 'Three': 3, 'Five': 5, 'Two': 2} | |
| sample_dict_sorted_list = sorted(sample_dict.items(), key=lambda x : x[1]) | |
| for item in sample_dict_sorted_list: | |
| print item |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def ranks(scores): | |
| result = [] | |
| sorted_list = sorted(scores, reverse=True) | |
| for score in scores: | |
| rank = sorted_list.index(score) + 1 # index() returns the lowest index in list that obj appears. | |
| result.append(rank) | |
| return result |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def flipping_bits(a): | |
| # in this case, it flips a 32-bit unsigned int | |
| return ~a & 0xFFFFFFFF | |
| n = int(raw_input()) #faster than n = input() , since input() executes the line as python command | |
| res = [] | |
| for i in range(0,n): | |
| a = int(raw_input()) | |
| res.append(flipping_bits(a)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import datetime | |
| class Person(object): | |
| def __init__(self, name): | |
| """create a person called name""" | |
| self.name = name | |
| self.birthday = None | |
| self.lastName = name.split(' ')[-1] | |
| def getLastName(self): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import string | |
| ### DO NOT MODIFY THIS FUNCTION ### | |
| def load_words(file_name): | |
| ''' | |
| file_name (string): the name of the file containing | |
| the list of words to load | |
| Returns: a list of valid words. Words are strings of lowercase letters. | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function palindrome(str) { | |
| var re = /[a-zA-Z0-9]/; | |
| var stripped_str_arr = []; | |
| for (var letter in str) { | |
| if (str[letter].match(re)) { | |
| stripped_str_arr.push(str[letter].toLowerCase()); | |
| } | |
| } | |
| var rev_array = stripped_str_arr.slice().reverse(); | |
| var rev_str = rev_array.join(""); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "vars": { | |
| "@gray-base": "#000", | |
| "@gray-darker": "lighten(@gray-base, 13.5%)", | |
| "@gray-dark": "lighten(@gray-base, 20%)", | |
| "@gray": "lighten(@gray-base, 33.5%)", | |
| "@gray-light": "lighten(@gray-base, 46.7%)", | |
| "@gray-lighter": "lighten(@gray-base, 93.5%)", | |
| "@brand-primary": "darken(#428bca, 6.5%)", | |
| "@brand-success": "#5cb85c", |