Skip to content

Instantly share code, notes, and snippets.

View gsans's full-sized avatar
🚁
Hawaii is Awesome

Gerard Sans gsans

🚁
Hawaii is Awesome
View GitHub Profile
@gsans
gsans / hello-world_test.sol
Created February 25, 2022 12:28
Solidity unit test
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.10;
// This import is automatically injected by Remix
import "remix_tests.sol";
// This import is required to use custom transaction context
// Although it may fail compilation in 'Solidity Compiler' plugin
// But it will work fine in 'Solidity Unit Testing' plugin
import "remix_accounts.sol";
@gsans
gsans / hello-world_test.sol
Created February 25, 2022 12:28
Solidity unit test
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.10;
// This import is automatically injected by Remix
import "remix_tests.sol";
// This import is required to use custom transaction context
// Although it may fail compilation in 'Solidity Compiler' plugin
// But it will work fine in 'Solidity Unit Testing' plugin
import "remix_accounts.sol";
@gsans
gsans / Profile.vue
Created January 14, 2022 19:46
codez052: add send message to Profile page
<template>
<div id="app" class="flex container h-screen w-full">
<div class="flex container h-screen w-full">
<SideNav />
<div class="w-full md:w-2/3 lg:w-1/2 h-full overflow-y-scroll" v-scroll:bottom="loadMore">
<div class="px-5 py-3 border-b border-lighter flex items-center">
<button @click="gotoHome()" class="rounded-full md:pr-2 focus:outline-none hover:bg-lightblue">
<i class="fas fa-arrow-left text-blue"></i>
</button>
@gsans
gsans / UserNewMessage.vue
Created January 14, 2022 19:45
codez051: new message user details
<template>
<div v-if="profile.id !== user.id" @click="user.followedBy && selected(user)" class="w-full px-4 py-2 border-b hover:bg-lightest flex flex-row cursor-pointer" :class="!user.followedBy?'cursor-not-allowed opacity-60':''">
<div class="flex-none">
<img :src="`${user.imageUrl || 'default_profile.png'}`" class="h-12 w-12 rounded-full"/>
</div>
<div class="ml-2 flex flex-col w-full">
<div class="flex flex-row justify-between w-full">
<div class="flex flex-col">
<p class="font-bold">{{ user.name }}</p>
<p class="text-dark text-sm">@{{ user.screenName }} {{!user.followedBy?"cant'be messaged":''}}</p>
@gsans
gsans / ResultsNewMessage.vue
Created January 14, 2022 19:44
codez050: new message results
<template>
<div>
<div v-for="result in results" :key="result.id">
<UserNewMessage
v-if="result.screenName"
:user="result"
@selected="selected"
/>
</div>
</div>
@gsans
gsans / NewMessageOverlay.vue
Created January 14, 2022 19:42
codez049: new message overlay
<template>
<div class="fixed w-full h-full top-0 left-0 flex items-center justify-center">
<div class="absolute w-full h-full bg-gray-900 opacity-50" @click.prevent="$emit('update:showNewMessageModal', false);"></div>
<div class="modal-main bg-white mx-auto rounded-lg z-50 overflow-y-auto w-full sm:w-3/5 md:w-2/5 max-h-full">
<div class="pl-1 pr-4 py-1 h-16 border-b-2 border-lightblue">
<div class="flex flex-row mt-1 ml-4">
<i @click="$emit('update:showNewMessageModal', false);" class="fas fa-times text-blue text-2xl w-10 h-10 mr-1 xl:mr-6 mt-1 pt-1 pl-3 rounded-full bg-white hover:bg-lightblue"></i>
<p class="text-xl pt-1 font-bold mt-1">New message</p>
</div>
@gsans
gsans / time.js
Created January 14, 2022 19:31
codez048: messages time filter
import moment from 'moment';
moment.updateLocale('en', {
monthsShort: [
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
],
});
export default function time(_date) {
@gsans
gsans / SideNav.vue
Created January 14, 2022 19:29
codez047: messages side navigation
<template>
<div class="w-1/6 md:w-1/12 xl:w-1/6 border-r border-lighter lg:px-6 py-2 flex-col justify-between hidden sm:flex">
<div>
<button class="h-12 w-12 hover:bg-lightblue text-3xl text-blue rounded-full">
<i class="ml-2 fab fa-twitter"></i>
</button>
<div>
<button @click="open('Home')" class="focus:outline-none hover:text-blue flex items-center px-4 py-2 hover:bg-transparent md:hover:bg-lightblue rounded-full mr-auto mb-1">
<i class="fa fa-home" :class="$route.name == 'Home'?'text-2xl':'text-xl'" aria-hidden="true"></i>
<p class="text-lg ml-4 text-left hidden xl:block" :class="$route.name == 'Home'?'font-bold':''"> Home</p>
@gsans
gsans / getters.js
Created January 14, 2022 19:26
codez046: messages vuex getters
import Moment from 'moment';
export default {
profile: state => state.profile,
tweets: state => state.tweets.tweets,
nextTokenTweets: state => state.tweets.nextToken,
joinedDate: state => Moment(state.profile.createdAt).format('MMMM YYYY'),
isSelf: state => screenName => state.profile.screenName == screenName,
followers: state => state.followers.followers,
nextTokenFollowers: state => state.followers.nextToken,
@gsans
gsans / mutations.js
Created January 14, 2022 16:04
codez045: messages vuex mutations
export default {
PROFILE_SET(state, profile) {
state.profile = profile;
},
TWITTER_TIMELINE(state, { tweets, nextToken }) {
state.tweets.tweets = tweets;
state.tweets.nextToken = nextToken;
},
TWITTER_CREATE(state, newTweet) {