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
| # UVA378 - Intersecting Lines | |
| # https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=314 | |
| readints=lambda:map(float, input().strip('\n').split()) | |
| n=int(input()) | |
| EPS=1**-9 | |
| class Point: | |
| def __init__(self,x,y): |
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
| // CallApplyBind examples, cuz i occassionally forget call and apply | |
| function fn(x,y) { | |
| return x+y+this.z | |
| } | |
| var obj={ z: 4 }; | |
| var objfn=fn.bind(obj); |
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
| class UnionFind { | |
| public: | |
| vector<int> parent; | |
| int getParent(int v) { | |
| if (parent[v]==v) return v; | |
| return getParent(parent[v]); | |
| } | |
| void unionn(int v, int w) { | |
| int vp=getParent(v); | |
| int wp=getParent(w); |
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
| class UnionFind: | |
| def __init__(self, N): | |
| self.parent=[i for i in range(N+1)] | |
| def findParent(self, v): | |
| if self.parent[v]==v: return v | |
| else: return self.findParent(self.parent[v]) | |
| def union(self, v, w): | |
| vp=self.findParent(v) | |
| wp=self.findParent(w) | |
| self.parent[vp]=wp |
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 React, { Component } from 'react'; | |
| import logo from './logo.svg'; | |
| import { connect } from 'react-redux'; | |
| import './App.css'; | |
| let nextTodoId = 0 | |
| const addTodo = (text) => ({ | |
| type: 'add', | |
| id: nextTodoId++, |
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
| var a=2; | |
| var obj={a: 3}; | |
| function getA() { return this.a; } | |
| console.log(getA()); // 2 | |
| var tmp=getA.bind(obj); | |
| console.log(tmp()); // 3 | |
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 UIKit | |
| class ViewController: UIViewController, UICollectionViewDelegate, UICollectionViewDataSource { | |
| @IBOutlet weak var embeddedCV: UICollectionView! | |
| override func viewDidLoad() { | |
| super.viewDidLoad() | |
| // make ourselves the delegate and data source of the CV. | |
| embeddedCV.delegate = 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
| /* | |
| There is a button in each UICVCell, and we want to pass data based on a specific cell when we segue. | |
| */ | |
| override func prepare(for segue: UIStoryboardSegue, sender: Any?) { | |
| let destController = segue.destination as! CommentController | |
| if let selectedFeedCell = (sender! as AnyObject).superview!?.superview as? FeedCell { | |
| let indexPath = self.collectionView!.indexPath(for: selectedFeedCell)! | |
| let row = indexPath.row | |
| destController.feedItemInd = row |
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 numpy as np | |
| # NOTE: numpy uses radians for its angles | |
| # constants | |
| PI = np.pi | |
| cos = lambda ang: np.cos(ang) | |
| ncos = lambda ang: -1*np.cos(ang) | |
| sin = lambda ang: np.sin(ang) | |
| nsin = lambda ang: -1*np.sin(ang) |