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 isObject(obj) { | |
return typeof obj==='object' && !Array.isArray(obj) && obj !== null; | |
} | |
// object -> array | |
function paramStrGen(obj){ | |
var finalKey = []; | |
Object.keys(obj).sort().forEach(key => { |
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
""" | |
Give an file as input which has following data | |
3 love | |
6 computers | |
2 dogs | |
4 cats | |
1 I | |
5 you |
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
# Backup | |
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql | |
# Restore | |
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE | |
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
exports.handler = (event, context, callback) => { | |
const response = { | |
statusCode: 301, | |
headers: { | |
Location: 'https://google.com', | |
} | |
}; | |
return callback(null, response); | |
} |
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
# 5-fold cross validation | |
import numpy as np | |
import pandas as pd | |
from sklearn.model_selection import KFold | |
fold5 = KFold(n_splits=5,shuffle=False,random_state=1) | |
scores = [] | |
df = pd.read_csv('iris.csv',header=None) | |
X = df.drop(columns=[4]) | |
Y = df[4] | |
knn = KNeighborsClassifier(n_neighbors = 9) |
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
image: ubuntu:latest | |
variables: | |
WORK_DIR: ${CI_PROJECT_NAME} | |
BRANCH: ${CI_COMMIT_REF_NAME} | |
stages: | |
- staging | |
- production | |
staging: |
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
'use strict'; | |
class LinkList { | |
constructor() { | |
this.head = null; | |
} | |
addNode(value) { | |
const node = new Node(value); | |
if (this.head) { | |
node.next = this.head; |
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
"use strict"; | |
const fizzBuzz = () => { | |
for (let i = 1; i <= 100; i++) { | |
const mod5 = i % 5, | |
mod3 = i % 3; | |
if (mod3 === 0 && mod5 === 0) console.log("FizzBuzz"); | |
else if (mod3 === 0) console.log("Fizz"); | |
else if (mod5 === 0) console.log("Buzz"); | |
else console.log(i); |
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
const vowelRegex = new RegExp('^[aeiou]', 'g'); | |
function pigLatin(str){ | |
if (vowelRegex.test(str)) { | |
return `${str}way`; | |
} else { | |
const first = str.slice(0, 1); | |
const rem = str.slice(1, str.length); | |
return `${rem}${first}ay`; | |
} | |
} |
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
override func layoutSubviews() { | |
super.layoutSubviews() | |
var subviews: [Any] = self.subviews | |
let subview = subviews[0] as! UIView | |
if subview.classForCoder.debugDescription() == "UITableViewCellDeleteConfirmationView" { | |
subview.frame.size.height = 50 | |
subview.frame.origin.y = 10 | |
subview.clipsToBounds = true | |
subview.layer.masksToBounds = true | |
} |
NewerOlder