Skip to content

Instantly share code, notes, and snippets.

Avatar
🇪🇬
البحث عن الحقيقة

David Awad davidawad

🇪🇬
البحث عن الحقيقة
View GitHub Profile
View ExampleToken.java
/* Create an instance of TransactionState using the houseState token and the notary */
TransactionState<HouseState> transactionState = new TransactionState<>(houseState, notary);
/* Create the house token. Token SDK provides the CreateEvolvableTokens flow which could be called to create an
evolvable token in the ledger.*/
subFlow(new CreateEvolvableTokens(transactionState));
/* Create an instance of the non-fungible house token with the owner as the token holder.
* Notice the TokenPointer is used as the TokenType, since EvolvableTokenType is not TokenType, but is
* a LinearState. This is done to separate the state info from the token so that the state can evolve independently.
View sampleFlow.java
public TokenIssueFlowInitiator(Party owner, int amount) {
this.owner = owner;
this.amount = amount;
}
@Suspendable
@Override
public SignedTransaction call() throws FlowException {
Party notary = getServiceHub().getNetworkMapCache().getNotaryIdentities().get(0);
View exampleContract.java
public class TokenContract implements Contract {
public static String ID = "bootcamp.TokenContract";
@Override
public void verify(LedgerTransaction tx) throws IllegalArgumentException {
CommandWithParties<TokenContract.Commands> command = requireSingleCommand(tx.getCommands(), TokenContract.Commands.class);
List<ContractState> inputs = tx.getInputStates();
List<ContractState> outputs = tx.getOutputStates();
View exampleState.java
@belongstocontract(tokencontract.class)
public class tokenstate implements contractstate {
private final party issuer;
private final party owner;
private final int amount;
private final list<abstractparty> participants;
public tokenstate(party issuer, party owner, int amount) {
this.issuer = issuer;
@davidawad
davidawad / corda_accounts_short.java
Created Jun 30, 2020
quick java snippet of corda accounts sdk
View corda_accounts_short.java
@Suspendable
@Override
public String call() throws FlowException {
//Generate accountinfo & AnonymousParty object for transaction
AccountInfo issuerAccountInfo = UtilitiesKt.getAccountService(this).accountInfo(issuer).get(0).getState().getData();
AccountInfo ownerAccountInfo = UtilitiesKt.getAccountService(this).accountInfo(owner).get(0).getState().getData();
AnonymousParty issuerAccount = subFlow(new RequestKeyForAccount(issuerAccountInfo));
AnonymousParty ownerAccount = subFlow(new RequestKeyForAccount(ownerAccountInfo));
View create docker service that exposes port.
Create a docker swarm service
docker service create \
--name=redis \
--publish=6379:6379/tcp \
--constraint=node.role!=manager \
--mount=type=bind,src=/var/run/docker.sock,dst=/var/run/docker.sock \
arm32v7/redis:latest
@davidawad
davidawad / grammarly_irritation.js
Created Jan 30, 2020
fixing Grammarly to work automatically within chrome or any js page
View grammarly_irritation.js
var SELECTOR = "grammarly-card div div div div div div div div";
function grammarCorrection(){
// find the grammarly div and click within the menu to correct
var evt = new MouseEvent("click");
g = $("grammarly-card div div div div div div div div")[1];
@davidawad
davidawad / last_business_day.ics
Created Jan 17, 2020
calendar event on last business day of every month, works in google calendar.
View last_business_day.ics
BEGIN:VCALENDAR
VERSION:2.0
BEGIN:VEVENT
RRULE:FREQ=MONTHLY;INTERVAL=1;WKST=MO;BYDAY=MO,TU,WE,TH,FR;BYSETPOS=-1
SUMMARY:Pay Day
DTSTART;VALUE=DATE:20190131
SEQUENCE:0
DESCRIPTION:I Get Paid
END:VEVENT
END:VCALENDAR
@davidawad
davidawad / fuckmylife.js
Created Oct 14, 2019
kill service workers
View fuckmylife.js
navigator.serviceWorker.getRegistrations().then(function(registrations) { for(let registration of registrations) { registration.unregister() } })
@davidawad
davidawad / fuckmylife.js
Created Oct 14, 2019
kill service workers
View fuckmylife.js
navigator.serviceWorker.getRegistrations().then(function(registrations) { for(let registration of registrations) { registration.unregister() } })
You can’t perform that action at this time.