Skip to content

Instantly share code, notes, and snippets.

@cursorial
cursorial / Efficient Swap
Last active December 20, 2015 09:30
Swap two integers without using a temporary variable
a = input('Enter Number 1: ')
b = input('Enter Number 2: ')
print 'Number 1: ', a
print 'Number 2: ', b
a -= b
b += a
a = b - a
float[] keycount = new float[26];
float[] xCoords = new float[26];
float[] yCoords = new float[26];
float spaceCount = 0;
float spaceXCoords; float spaceYCoords;
int count = 0;
PImage img;
void setup() {
String url = "http://www.moshi.com/image/clearguard/layout-us.jpg";
@keyframes snowfall {
0% {
top: -40px;
}
25% {
top: 250px;
left: 100px;
}
50% {
top: 500px;
@cursorial
cursorial / instagram_post_likes.js
Created April 17, 2021 19:29
Get Instagram Post Likes
const write = (arr) => { /* utility function to write our array of user id's somewhere */ }
const getGraphqlUrl = (queryHash, variables) => {
return `https://www.instagram.com/graphql/query/?query_hash=${queryHash}&variables=${encodeURIComponent(JSON.stringify(variables))}`
}
const getPageRequest = ({
err,
res,
body,
@cursorial
cursorial / update_query_hashes.js
Created April 17, 2021 20:17
Get Instagram Query Hashes
const updateQueryHashes = () => {
let urlManifest = window.__s.js
let urlManifestKeys = Object.keys(urlManifest)
let consumerFilePathKey = urlManifestKeys.filter((key) => {
return urlManifest[key].includes('Consumer.js')
})
let consumerFilePath = urlManifest[consumerFilePathKey]
fetch(consumerFilePath)
.then(res => res.text())
.then(data => {
@cursorial
cursorial / follow_user.js
Created April 17, 2021 20:30
Follow user
const requestHeaders = [
{
name: 'accept',
value: '*/*'
},
{
name: 'accept-language',
value: 'en-US;q=0.9,en;q=0.8'
},
{
@cursorial
cursorial / instagram_csrf_token.js
Created April 17, 2021 20:34
Get CSRF token on Instagram
const getCookieObject = () => {
let obj = {}
document.cookie.split(';').map((item) => {
const keyValArray = item.split('=')
try {
const key = keyValArray[0].trim()
const val = keyValArray[1].trim()
obj[key] = val
} catch (e) {}
})
@cursorial
cursorial / instagram-follow-users.js
Last active April 17, 2021 20:44
Follow users at random intervals
const random = (min, max) => {
return Math.random() * (max - min) + min;
}
const data = [/* user id array */]
data.map((item, index) => {
setTimeout(() => followUser(item), random(60000, 120000) * index)
})
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>My App</title>
</head>
<body>
<script src='./src/index.js'></script>
</body>
</html>
{
"name": "my-app",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"webpack": "^5.45.0",
"webpack-cli": "^4.7.2"
}
}