Skip to content

Instantly share code, notes, and snippets.

View brakmic's full-sized avatar
🏠

Harris Brakmić brakmic

🏠
View GitHub Profile
@brakmic
brakmic / bitcoin_transaction_simplified.cpp
Created October 8, 2017 16:53
Bitcoin Transaction (simplified)
class Transaction {
public:
const int32_t Version;
const uint32_t NumberOfInputs;
const vector<TransactionInput> CollectionOfInputs;
const uint32_t NumberOfOutputs;
const vector<TransactionOutput> CollectionOfOutputs;
const uint32_t LockTimestamp;
};
@brakmic
brakmic / bitcoin_blockheader_simplified.cpp
Created October 3, 2017 11:10
Bitcoin Block Header (simplified)
class BlockHeader {
public:
int32_t Version;
uint256 PreviousBlockHash;
uint256 MerkleRootHash;
uint32_t Timestamp;
uint32_t TargetToBeSolved;
uint32_t NonceForProofOfWork;
};
@brakmic
brakmic / bitcoin_block_simplified.cpp
Last active October 3, 2017 11:08
Bitcoin Block (simplified)
class Block {
public:
BlockHeader Header;
vector Transactions;
};
0x094f3723c13E9ee24de4AEb5b358FdD94D34315C
@brakmic
brakmic / WannaLaugh.ps1
Created May 12, 2017 22:57
stop WannaCry from spreading
# open powershell and execute this file
# let the window open
# if the script won't start because of local execution policy restrictions you can use "Set-Execution-Policy Bypass"
$createdNew = $False;
$mutex = New-Object -TypeName System.Threading.Mutex($true, "MsWinZonesCacheCounterMutexA", [ref]$createdNew);
@brakmic
brakmic / alternative_customer_state_selection.ts
Created April 11, 2017 11:55
alternative way of selecting customer state
this.store.select(appState => appState.customerState).subscribe(subState => {
const customerInstance = subState.customer; // not an observable but a concrete instance
});
@brakmic
brakmic / get_observable.ts
Created April 11, 2017 11:50
get customer observable
private getCustomerObservable() {
this.customer = getCustomer(this.store);
}
@brakmic
brakmic / dispatch_action.ts
Created April 11, 2017 11:21
dispatching an action
this.customerTable.on('select', (e: Event, dt: DataTables.DataTable,
type: string, indexes: number[]) => {
let row: INWCustomer = dt.rows(indexes[0]).data()['0'];
const customer = this.toLocalCustomer(row);
this.store.dispatch(this.customerActions.customerSelected(customer));
});
@brakmic
brakmic / heper_methods_state_extraction.ts
Last active April 11, 2017 11:14
helper methods for state extraction
export function getCustomerState(state$: Observable<IAppState>): Observable<ICustomerState> {
return state$.select(state => state.customerState);
}
export const getCustomer: (obs: Observable<IAppState>) => Observable<ICustomer> = compose(fromSubstates.getCustomer, getCustomerState);
@brakmic
brakmic / customer_effects.ts
Created April 11, 2017 10:47
handling customer effects
@Injectable()
export class CustomerEffects {
@Effect() customerSelected$: Observable<Action> = this.actions$
.ofType(CustomerActionTypes.SELECTED)
.map(action => {
let customer: ICustomer = _.cloneDeep(action.payload);
customer.active_debt = this.paymentService.activeDebt(customer.id);
customer.picture = this.imageService.imageUrl(customer.id);
return this.customerActions.customerInitialized(customer);