Skip to content

Instantly share code, notes, and snippets.

View linux08's full-sized avatar
📚
Learning.

David Abimbola linux08

📚
Learning.
View GitHub Profile
selectImage = async () => {
ImagePicker.showImagePicker(options, async (response) => {
if (response.didCancel) {
this.setState({ error: 'Image upload failed', loading: null });
} else if (response.error) {
this.setState({ error: 'Image upload failed', loading: null });
} else if (response.customButton) {
this.setState({ error: 'Image upload failed', loading: null });
upload = async () => {
this.setState({
loading: true
});
if (!this.state.uploadStatus) {
this.setState({ loading: null })
return alert('Image yet to be uploaded')
}
if (this.state.label === '') {
this.setState({ loading: null })
const code =fs.readFileSync('./contracts/StoreHash.sol').toString();
const solc = require('solc');
const compiledCode = solc.compile(code);
const abi =JSON.parse(compiledCode.contracts[':SaveAddress'].interface);
const SavingContract = new web3.eth.Contract(abi, '0xb1caf625d9d29421dfd8dae4a7a9083b4175f80a');
// where 0xb1caf625d9d29421dfd8dae4a7a9083b4175f80a is the ethereum address
exports.getScreenShot = async (req, res) => {
const { address } = req.query;
// web address you want to screenshot , Default is medium.com
const webAddress = `https://${( address || 'medium')}.com`;
try {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto(webAddress);
await page.screenshot({ path: `./assets/snapshot.png` });
await browser.close();
exports.getNews = async (req, res) => {
const { address } = req.query;
const webAddress = `https://${(address || 'news.ycombinator')}.com`;
try {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto(`${webAddress}`, { waitUntil: 'networkidle2' });
await page.pdf({ path: `./assets/news.pdf`, format: 'A4' });
exports.scrapeTwittter = async (req, res) => {
let ret = [];
const { search } = req.query;
try {
const browser = await puppeteer.launch({ args: ['--no-sandbox', '--disable-setuid-sandbox'] });
const page = await browser.newPage();
await page.goto(`https://twitter.com/search?f=tweets&vertical=default&q=${search}&src=typd`);
//set viewport for the autoscroll function
await page.setViewport({
width: 1200,
const path = require('path');
const glob = require('glob');
const fs = require('fs');
const loadMetroConfig = require('@react-native-community/cli/build/tools/loadMetroConfig')
.default;
const loadConfig = require('@react-native-community/cli/build/tools/getLegacyConfig')
.default;
const Server = require('metro/src/Server');
package models
import (
"github.com/jinzhu/gorm"
)
//User struct declaration
type User struct {
gorm.Model
Name string
package utils
import (
"auth/models"
"fmt"
"log"
"os"
"github.com/jinzhu/gorm"
_ "github.com/jinzhu/gorm/dialects/postgres" //Gorm postgres dialect interface
import (
"auth/models"
"auth/utils"
"encoding/json"
"fmt"
"net/http"
"golang.org/x/crypto/bcrypt"
)