Skip to content

Instantly share code, notes, and snippets.

View julianeon's full-sized avatar

Julian Martinez julianeon

View GitHub Profile
@julianeon
julianeon / emacs_functions.lisp
Last active November 2, 2023 19:27
Helper functions I used in Emacs. Most were written by me but some were copied from the Internet.
(defun insert-and-indent-line-above ()
(interactive)
(push-mark)
(let*
((ipt (progn (back-to-indentation) (point)))
(bol (progn (move-beginning-of-line 1) (point)))
(indent (buffer-substring bol ipt)))
(newline)
(previous-line)
(insert indent)))
const Web3 = require('web3');
const fs = require('fs');
const gasPriceTokenApproval = '5.5'; // Set your desired gas price in Gwei for token approval
const gasPricePancakeSwap = '10';
// Connect to the BSC network using a provider URL
const providerUrl = 'https://bsc-dataseed.binance.org';
const web3 = new Web3(providerUrl);
@julianeon
julianeon / board_colors_clicker.js
Last active December 12, 2021 22:47
A board where you can set foreground and background colors, and also tap blocks to set colors.
import styled from 'styled-components';
import { useMemo, useRef, useState, useEffect, createContext, useContext } from 'react';
const Butn=styled.button`
background: ${props => props.primary ? "navy" : "#4CAF50"};
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
@julianeon
julianeon / board_clicker.js
Created December 12, 2021 01:40
Board clicker in React.
import styled from 'styled-components';
import { useMemo, useState, useEffect, createContext, useContext } from 'react';
const Fleg=styled.div`
display: flex;
`
const Col=styled.div`
display: flex;
justify-content: center;
@julianeon
julianeon / solana_anchor_tests_tic_tac_toe_program.js
Last active April 8, 2024 15:54
A working test of the program in project-serum/anchor/tests/tictactoe, mostly the .js test shown there in /tests dir, but fixed to work (1 constraint removed) w/2 new tests added at bottom.
const anchor = require('@project-serum/anchor');
describe('tiktaktoe', () => {
anchor.setProvider(anchor.Provider.env());
const program = anchor.workspace.Tictactoe;
let dashboard = anchor.web3.Keypair.generate()
let game = anchor.web3.Keypair.generate()
let player_o = anchor.web3.Keypair.generate()
@julianeon
julianeon / reddit_api_top_subreddit_posts.go
Last active December 6, 2021 18:29
Reddit API script: fetching the top subreddit posts for "JavaScript" and writing to file.
package main
import (
"context"
"fmt"
"io"
"os"
"log"
"github.com/vartanbeno/go-reddit/reddit"
)
@julianeon
julianeon / one-file-with-images.html
Created October 21, 2021 04:03
1 HTML file with images inline.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width-device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Card Game</title>
<style>
.some-page-wrapper {
margin: 15px;
@julianeon
julianeon / react-form.js
Created July 9, 2020 02:41
React form using API Gateway Endpoint
import React, { useState } from 'react'
import axios from 'axios';
const App = () => {
const [values, setValues] = useState({name: '', message: '', email: ''})
const [sent, setSent] = useState(false);
const handleChange = e => {
const {name, value} = e.target
setValues({...values, [name]: value})
}
@julianeon
julianeon / chat.postMessage.js
Created June 16, 2020 00:00
chat.postMessage method working script using JavaScript
const request = require('request');
let token="xoxo-xoxo";
let channelid="C00LR00M";
var url = "https://slack.com/api/chat.postMessage";
var auth_token = token; //Your Bot's auth token
var headers = {
"Authorization": "Bearer " + auth_token,
"Content-Type" : "application/json"
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>JavaScript GET Request</title>
<style>
.box {