Skip to content

Instantly share code, notes, and snippets.

View matiasvillaverde's full-sized avatar

Mati matiasvillaverde

View GitHub Profile
- (void)getCacheOf:(NSString*) documentID withProyectName: (NSString *)proyect {
//Get the proyect also, because is using the default one...
MSIPreferencesStore * store = [MSIPreferencesStore preferencesStore];
MSIDevicePreferences *devicePreferences = [store preferencesCopy];
WebServerList *webServerList = [devicePreferences getWebServers];
MSIProjectConfiguration *project = [webServerList getProjectConfigurationByProjectName:proyect];
/******************************************************************************
* Compilation: javac Quadratic.java
* Execution: java Quadatic b c
*
* Given b and c, solves for the roots of x*x + b*x + c.
* Assumes both roots are real valued.
*
* % java Quadratic -3.0 2.0
* 2.0
/******************************************************************************
* Compilation: javac Distance.java
* Execution: java Distance x y
*
* Prints the distance from (x, y) to the origin, where x and y
* are integers.
*
* % java Distance 45 -2
* distance from (3, 4) to (0, 0) = 45.044422518220834
*
// MARK: - We use it to know when the microstrategy VC is created or to handle the error.
extension NavigationManager: MSTRVCRetrieverDelegate {
/**
This method is called when the VCRetriever encountered an Error while fetching the VC
*/
func retriever(retriever: MSTRVCRetriever!, didFailWithError error: MSTRError!) {
//ERROR is always nil. We should be able to know if the password is not correct, or why the user can't access.
struct Block {
let timestamp: Date
let data: String
let previousBlockHash: Int
let hash: Int
}
struct Block {
init(timestamp: Date, data: String, previousBlockHash: Int) {
self.timestamp = timestamp
self.data = data
self.previousBlockHash = previousBlockHash
// For now lets just get some fields, concatenate them, and calculate a hash
let basicHash = String(previousBlockHash) + data + String(timestamp.timeIntervalSince1970)
struct Blockchain {
var blocks: [Block]
}
struct Blockchain {
var blocks = [Block]()
mutating func addBlock(_ data: String) {
guard let lastBlock = blocks.last else { fatalError("Failed to find genesis block.") }
let newBlock = Block(timestamp: Date(), data: data, previousBlockHash: lastBlock.hash)
blocks.append(newBlock)
}
}
func NewGenesisBlock() -> Block {
return Block(timestamp: Date(), data: "The Times 03/Jan/2009 Chancellor on brink of second bailout for banks", previousBlockHash: 0)
}
import Foundation
struct Block {
init(timestamp: Date, data: String, previousBlockHash: Int) {
self.timestamp = timestamp
self.data = data
self.previousBlockHash = previousBlockHash