creacode
creacode
Creative Coding
42 posts
Blog for Creative Coding
Don't wanna be here? Send us removal request.
creacode · 7 years ago
Link
If only this had been up a couple of weeks ago!
0 notes
creacode · 7 years ago
Text
Summary
What went well:
I did create a working twitter bot using live data
I did create a working weather API using live data that it continuously gathers
I did previously create the mood rings in CSS, HTML and JS
I did make numerous changes myself (that worked) rather than simply following instructions
I did start to understand more about coding in general
 What needs improving:
I did not manage to work out how to make the twitter bot output a picture
I could not connect the weather api and the twitter bot even though I’m sure it’s possible
I overcomplicated matters – next time I should start with something MUCH more simple
I misunderstood the instructions and spent time trying to work with the wrong coding languages
0 notes
creacode · 7 years ago
Text
Twitter stuff 5 - it starts to work
Since we had another week to add stuff to the blog I decided to have another go at improving the work I’d done.
Tumblr media
As usual it took me a lot longer and more errors but I eventually created a twitter bot using node.js. I don’t think this is exactly what was asked of me, but I simply can’t find a way to do it in P5, because all the instructions I can find are for Ruby or Python or node. At least all the instructions that have made sense. So this will have to do for a start because I can at least use it to use live streaming data and tweet an image.
But first I got it to tweet at all, then search for various words using the track parameter, then search for various words with a geolocation too. Had to get my geocode from here http://en.mygeoposition.com/ because it’s not the same as just long and lat.
Tumblr media
Then I went to http://www.idfromuser.com/ to get the id number of BBC weather watchers on twitter (it’s 3663259516).
Then I decided to go simple, and just look for one of my “calm” words.
Tumblr media
After my twitter archive eventually appeared in my inbox I spent quite a while trying to get this code to work:
const Twit = require('twit')
const config = require('./config')
 const bot = new Twit(config)
 const filePath = path.join(Sam\tweebot-play\src'.\twitter-archive\tweets.csv')
const tweetData =
fs.createReadStream(filePath)
 .pipe(csvparse({
   delimiter: ','
 }))
 .on('data', row => {
  console.log(row[5])
 })
 It failed and eventually I had to give up. Nothing online helps.
 I’m sure there’s a way to combine my weather api with this twitter bot but I just can’t figure it out.
 From here https://hackernoon.com/create-a-simple-twitter-bot-with-node-js-5b14eb006c08 this part is important info to save:
Now to automate this action we defined above, we can use JavaScript’s timer function setInterval() to search and retweet after a specific period of time.
 // grab & retweet as soon as program is running...
retweet();
// retweet in every 50 minutes
setInterval(retweet, 3000000);
 Please note that all JavaScript’s Timer functions take the amount of time argument in milliseconds.
When I work out how to post a picture this will make it an actual bot. But all I can find is ways to post random pictures, not how to choose which pictures to post.
I decided to test out the setInterval function on my weather node api, setting it first for every five minutes (just taking a zero off the number above), then, if that worked, for every day, every 86400000 milliseconds.
Obvs the wording is different because it’s not a tweet:
function intervalFunc() {
console.log('Cant stop me now!');
}
 setInterval(intervalFunc, 1500);
 Obvs all this does is write Can’t stop me now every five minutes, which isn’t very useful. I’ve asked for help on stackexchange. ETA: got the help amazingly quickly, and now it works!
Tumblr media
*Attach screenshot of working console thingy
Back to the twitterbot. I can still get it to search for my various search terms but trying to add the setInterval function causes it all to stop working. It looks the same as my weather file, so I’m not sure why it won’t work here.
Tumblr media
Anyway, here are the relevant files:
http://helenseviltwin.com/juliette/.env
http://helenseviltwin.com/juliette/bot.js
http://helenseviltwin.com/juliette/index3.js
http://helenseviltwin.com/juliette/weatherapp3.html
(All here: http://helenseviltwin.com/juliette/)
0 notes
creacode · 7 years ago
Text
Twitter bot stuff 4
Step one: I created a new Twitter account using my uni email and the username Mood_Ring_Bot
Step two: Registered as a new app here https://apps.twitter.com/app/new using the http://helenseviltwin.com/juliette/ web address and create access token.
Step three: Install node.js and make sure it’s added to path.
Step four: Open command prompt via win + x. Install grunt using the npm install -g grunt-init command.
Now I’m looking at various sites, and none of the instructions make any sense. For example, “Setup an empty directory and initialise it with:$ npm init to configure this web application with package.json file. Then create two new files: bot.js & config.js in that directory.”
What does set up an empty directory mean? What does initialise it mean? How do you create files in a directory? Looking online doesn’t answer this. Are these Mac terms maybe? Bear in mind I’ve done all this many, many times when trying to create a bot using Ruby and Python. Not having a Mac is a HUGE disadvantage but I can’t afford one
Step 5: Open one of the git files in Editplus and try playing around with it. Add the basic stuff like the name of the bot, the access token and keys, etc.
Step 5: Go to http://gruntjs.com/getting-started Install the grunt-inti-jquery template via command prompt.
Now I’m stuck and AGAIN I can’t find any instructions that work for Windows. They’re all for Mac or Linux. This is very frustrating.
Step 6: Sign up for a twitter feed thing.
It asks for permission, but when I grant it, all it does is ask for permission again.
So I can’t move any further forward here.
Having asked around, that feed would probably do too much of the work for me anyway, so shouldn’t be used for this project.
Step 7: Added a photo to my twitter profile
Step 8: http://techknights.org/workshops/nodejs-twitterbot/
This one actually explains the “create empty directory” bit:
Open up a terminal or command prompt.
mentally think of where you want your project folder to go (for example, on the Desktop)
In the terminal, type: cd and then navigate to the directory of your choice. (i.e. cd Desktop)
make a folder in that directory by doing mkdir twitterbot
now go in to that folder by doing: cd twitterbot/
But it’s gone wrong:
I’ve carried on with the instructions, but there seems to be a problem again:
https://www.npmjs.com/package/twitter - documentation for Twitter
Now I’m getting an error message saying 'var' is not recognized as an internal or external command, operable program or batch file.
This should help, from here: https://github.com/nodejs/node/issues/7521: Make sure to run npm install request (outside of the node REPL) before trying to run require('request')
But it doesn’t. I still get the same error message. This is probably because the package didn’t fully install. I’ll try somewhere else.
It looks like the problem might be that I HAVE to use C again. But I’ve run out of space on C. Adobe won’t uninstall and is taking up almost all of the available space.
I’ve gone back to the beginning (after removing Word to make space on C), getting rid of the node I currently have installed, and doing everything again. This is roughly the 18th time I’ve gone back to the beginning again and it’s very frustrating.
The instructions on that page say to install node v 5.5.5 stable, and that’s not really available any more. Hope that doesn’t mess it up too much.
I’m still getting error messages saying npm WARN saveError ENOENT: no such file or directory, open 'C:\Users\Sam\package.json'
So I tried a different version via the command npm install npm@latest -g
Then reinstalled twitter for node for about the millionth time.
STILL the same error - json is not installing.
After a lot of messing around and basically doing the same thing I think it might have installed. I’ve entered my user keys and secrets etc into the node command prompt.
Now it’s just gone back to error messages again and I give up.
0 notes
creacode · 7 years ago
Link
Mothgenerator is incredible - the type of bot I’d have loved to have made if I had the ability. It uses words, like I was planning to do with my bot, and it creates intricate moth designs where even changing one letter changes the design. 
1 note · View note
creacode · 7 years ago
Text
Failed code
http://helenseviltwin.com/juliette/weatherapp3.html
http://helenseviltwin.com/juliette/weatherapp3.css
http://helenseviltwin.com/juliette/weatherapp3.js
I would have worked more on the CSS if I could have got the JS to work, and would have worked more on the JS if I was certain it was what was required by the course, but I hadn’t realised data addiction was such an important part because it’s not in the PDF about the requirements, so it seems like a waste of time to work on the weather one more.
0 notes
creacode · 7 years ago
Link
Not working :(
0 notes
creacode · 7 years ago
Link
Still trying to get the weather app to work online as well as server side
0 notes
creacode · 7 years ago
Text
Data Scraping with Node.js
I’m trying something completely different. I’m not going to create a bot, just try to see if I can somehow or other use live data to change what mood ring picture emerges. Looking into web scraping tools.
Trying Octoparse first.
Tumblr media
Seemed OK until I got to loop on these instructions, and then nothing appeared.
I need to try something EVEN simpler.
I’m trying installing a weather thingy using the instructions here: https://codeburst.io/build-a-simple-weather-app-with-node-js-in-just-16-lines-of-code-32261690901d
Tumblr media
I’ve actually managed to install a json package, at least.
Then I get to this bit:
As I said, request is pretty easy to use. We just need to pass in our target url, and request returns a callback function. Our starter code looks like this:
const request = require('request');
request(url, function (err, response, body) {
if(err){
  console.log('error:', error);
} else {
  console.log('body:', body);
}
});
And I’m stuck because I don’t know what “pass in our target url” means (Google doesn’t enlighten me) and I don’t know where to put this code. It doesn’t go in command prompt by the looks of it. Maybe in index.js?
Then I had to use cd in the command prompt to go down to the desktop, then the node-weather folder, and only THEN could I put in the command node index.js
And it WORKED!
Tumblr media
OMG! It’s working a bit!
Yes, it really does output something saying what the weather in London is!
Now I need to turn that info into one of my images.
I’ve copied all the mood ring files into the node-weather folder.
Now I think I need to, at minimum, do an if function for the temperature. If this works I can add others for words like cloudy and sunny later. Or possibly go straight to the description - let’s see what the options there are.
The clouds section has a percentage, and 0% is bright whereas 100% is completely overcast, and London can go from one to the other easily. If weather.main.temp is the temperature than weather.main.clouds must be the cloud cover. No, took a couple of goes and it turns out it’s weather.clouds.all
This works.
C:\Users\Sam\Desktop\node-weather>node index.js
It's 92 in London!
(What showed up in command prompt)
But I need that to turn out an image, and not just one image, but one of several based on variable cloud cover levels.
I’ve experimented with the yargs thing, and, as instructed, used it to create a variable for any city. That works. For example:
C:\Users\Sam\Desktop\node-weather>node index.js -c Boston
It's 90 percent cloudy in Boston!
C:\Users\Sam\Desktop\node-weather>
I’ve been playing around and I can get it to say various things about the weather:
C:\Users\Sam\Desktop\node-weather>node index.js
It's 92 percent cloudy, 71 percent humid, and 9.12 degrees in London!
C:\Users\Sam\Desktop\node-weather>
But I still can’t work out how to get those numbers to show different results.
After another few hours (hah) I’ve discovered that I simply can’t use this node.js script via a website, only on my command line. But I also can’t view images via my command line. So how do I use “translate data from input into visual element?”)
I’m trying to install browserify to sort of convert my node.js into javascript that can be used in a browser. Has it worked?
Tumblr media
No. The resulting bundle.js appears to have nothing whatsoever to do with the file I created.
Ideas: If I got this to work in javascript instead, I could also do it with the brightness of the image coming from the cloudiness and saturation coming from the temperature. Perhaps make a different picture, like a sky, in pixelart and use that as a reference for css coding. I could add time of day via a separate command and use that for hue. Could add sound for rain, wind, sunny day etc.
I could include the parameters for sunrise and sunset and simulate the sky further.
0 notes
creacode · 7 years ago
Text
First emotions list
Sad/insecure
 Blank
Blue
Sad
Sadness
Sadly
Unhappy
Unhappiness
Unhappily
Sorrowful
Sorrow
Sorrowfully
Intimidated
Intimidate
Intimidating
Intimidatingly
Depressed
Depression
Depressingly
Depressive
Depressant
Miserable
Misery
Miserably
Down
Gloomy
Gloom
Heartbroken
Hearbreak
Devastation
Devastated
Devastating
Devastatingly
Hurt
Hurtful
Hurting
Meh
Yawn
Boo
Woe
Woeful
Woefully
  Angry/passionate
 Mad
Angry
Anger
Red
Annoyed
Annoying
Annoyingly
Irritated
Irritating
Irritatingly
Fury
Furious
Infuriating
Infuriatingly
Vexed
Vexing
Fear
Enraged
Rage
Enragingly
Cross
Crossly
Frustrated
Frustration
Frustratingly
Rant
Aaargh
Aargh
Argh
Grr
Lust
Lustful
Passion
Passionate
Hot
Flustered
  Calm/reflective
 Calm
Calmly
Reflect
Reflective
Reflectively
Reflection
Thought
Thinking
Thoughtful
Thoughtfully
Think
Reflection
Reflective
Reflectively
Listen
Listening
Hear
Hearing
Attention
Plan
Remember
Recall
Memory
Analyse
Analysis
Hmm
Process
Surmise
Evaluate
Evaluation
Guess
Estimate
Serene
Serenity
Quiet
Quietly
Wonder
Wonderous
Awe
Comprehend
Comprehension
Relax 
 Happy/hopeful
 Happy
Happiness
Happily
Hope
Hopeful
Hopefully
Hoping
Joy
Joyful
Enjoy
Enjoying
Cheer
Cheerful
Glee
Content
Pleased
Pleasure
Delight
Delightful
Merry
Yay
Wahey
Woohoo
Fantastic
Amazing
Astounding
Wonderful
Magnificent
Marvellous
Awesome
Outstanding
Optimism
Optimistic
Optimist
Upbeat
Buoyant
 Lively/sociable
 Live
Affection
Affectionate
Lively
Living
Sociable
Friends
Friendly
Befriend
Like
Liking
Love
Loving
Party
Celebrate
Celebration
Festival
Feast
Restaurant
Family
Energy
Energetic
Girlfriend
Boyfriend
Lover
Husband
Wife
Married
Conversation
Chat
Converse
Talk
Wow
Brilliant
Wedding
   Afraid, worried
 Yellow
Afraid
Worried
Worry
Worrying
Worryingly
Fear
Feared
Fright
Frightened
Nervous
Nervously
Nerves
Scared
Scary
Anxious
Anxiety
Angst
Eek
Pensive
Worrywort
Dystopia
War
Nuclear
Divorce
Wrong
Doubt
Doubting
Doubtful
Wary
Distrustful
Mistrustful
Disbelieving
Alarm
Alarmed
Alarming
Alarmingly
Suspect
Suspicious
0 notes
creacode · 7 years ago
Text
https://wire.wisc.edu/quizzesnmore/Emotionwords.aspx Short emotions words list that could be categorised and also extended to include different forms of the same words (adjectives, nouns, etc).
There’s also this list, though it’s mostly negative: https://web.sonoma.edu/users/s/swijtink/teaching/philosophy_101/paper1/listemotions.htm
0 notes
creacode · 7 years ago
Text
Robert Plutchik’s emotions wheel
Tumblr media
Each circle sector has an opposite emotion.
There are emotions with no colour because they’re mixed.
I still want to stick with six for my project; I can combine some of these. 
http://74.217.243.210/issues/feature/2001/4/the-nature-of-emotions/1 New Scientist article by Plutchik about the evolutionary roots of emotions. 
“ An emotion is not simply a feeling state. Emotion is a complex chain of loosely connected events that begins with a stimulus and includes feelings, psychological changes, impulses to action and specific, goal-directed behavior. That is to say, feelings do not happen in isolation. They are responses to significant situations in an individual's life, and often they motivate actions.” (Page 2)
-Presumably the emotions on tumblr/Twitter shown by my mood rings will be influenced by wider world events as well as events in the individuals’ lives
0 notes
creacode · 7 years ago
Text
Notes from Data Visualisation, by Richard Wright in Software Studies
“Visualization permits the apprehension of large amounts of data.
The flexibility of human vision can perceive emergent properties such as subtle
patterns and structures. It can compare small scale and large scale features at
the same time. It can also help with the discernment of artifacts or mistakes in
the gathering of the data itself.” (P80)
Like the way people use pie charts and graphs in economics. The mood ring of tumblr project would hopefully represent what people already know, or think they know, is the mood today, or show them an unexpected result, in a way they can process instantly. If the project kept going over time it would be very easy to show changes in mood and track if they related to days of the week (like Monday being sadder, maybe?) for example.
“Edward Tufte developed guidelines
and examples for how to design information graphics that are still infl uential
today. Tufte’s main concern is now referred to as the principle of being
“expressive”: to remove all unnecessary graphical ornamentation and show as
much data as possible; to “let the data speak for itself.”” (P80)
But for my project I want the outcome to be aesthetically pleasing and that’s equally as important as showing the data.
Some scientists working with fractal
modeling, such as Michael Barnsley, found that after a while they began to
“see” the rivers, trees, and clouds around them in terms of fractal mathematics,
13 internalizing concepts of self- similarity and strange attractors until they
had become a way of thinking and perceiving itself, as though turning the
whole world into a “natural” visualization. (P83)
People who play video games a lot sometimes start seeing the real world as part of the game
The use of memory and imagination in the discovery of a latent
resemblance is what makes the creation of knowledge possible. (P84)
Pattern recognition?
For the “Greenwich Emotion Map” (fi gure 5), groups of local
residents each received a Galvanic Skin Response unit which measured their
emotional arousal as they went for a walk around the neighbourhood. Every
four seconds their level of excitation was recorded along with their geographical
location as they reacted or failed to react to whatever coincidence of encounters,
sights, and smells the city channelled to them that day.
A physical version of tracking moods, and it’s in Greenwich! I’ve looked it up and you can download the whole map here: http://emotionmap.net/GreenwichEmotionMap.pdf
0 notes
creacode · 7 years ago
Text
Some PD tracks
https://puredata.info/community/member-downloads/tracks
Even on here the tracks are only available as MP3 downloads, so I’m still not sure how I can embed my PD tracks with my images. I can only think of including them as a download link too. 
This one’s a PD opera (credit: Terasonic): https://puredata.info/Members/terasonic/anomalous_divergences_in_the_course_of_fate_act_1_scene_2.mp3/view
And this one (credit: Claudius Maximus) https://puredata.info/Members/claudiusmaximus/copyme/swingsandroundabouts/sounds/swingsandroundabouts-200403301910-demo.ogg/view
0 notes
creacode · 7 years ago
Text
Creative coding examples
https://www.flickr.com/groups/2615752@N24/pool/with/26341527446/
Several of them are in the style of kaleidoscopes because that is a real-life example of semi-random art: https://www.flickr.com/photos/124341077@N07/26341527446/in/pool-2615752@N24/ (Credit: Elena Margarita Gancedo)
Tumblr media
0 notes
creacode · 7 years ago
Link
Most of these don’t use live data, but they’re still interesting as examples of how simple or complex a bot can be, and also what constitutes art
0 notes
creacode · 7 years ago
Text
https://vaporsoft.net/creating-a-tumblr-bot-from-scratch/ Applications Bad Translator
OAuth Consumer Key:
M5CYUxMjtwFkt6z0USEWU7DEU4UK3ijNj5dGA26vtgfft6c79M
Secret Key:  xeP1XnCqxyFfUz1JmI3caN3FBeh2ZS1uvgtuMvpVH5xWH6sKei   Explore API
// Authenticate via OAuth var tumblr = require('tumblr.js'); var client = tumblr.createClient({  consumer_key: 'M5CYUxMjtwFkt6z0USEWU7DEU4UK3ijNj5dGA26vtgfft6c79M',  consumer_secret: 'xeP1XnCqxyFfUz1JmI3caN3FBeh2ZS1uvgtuMvpVH5xWH6sKei',  token: 'lSBa4vn4whF8rsTFtTCGGg3xzmBxEbpqTfKBEuA4gjwiGy9MK1',  token_secret: '2uy3wWmLackUbF7EYEAnAy0SBBUwyrbPwTK3dHCfcC4kBBmRAq'
Cd simply wouldn’t recognise Ruby for ages so I reinstalled it a few times and edited it in the path because for some reason just ticking adding executables to the path wasn’t working. https://codingstories.net/how-to/how-to-fix-ruby-is-not-recognized-as-an-internal-or-external-command-operable-or-batch-file-error/
Realised the instructions on the page I was using weren’t for Windows (despite the bloke saying he doesn’t have a Mac!) so I had to swap the / for \
Shift + right click on a file to be able to copy the path
Tumblr media
Now it can’t find the gemfile. Sigh.
The tumblr_bot file now looks like:
require 'tumblr_client' # Authenticate via OAuth client = Tumblr::Client.new({  :consumer_key => 'M5CYUxMjtwFkt6z0USEWU7DEU4UK3ijNj5dGA26vtgfft6c79M',  :consumer_secret => 'xeP1XnCqxyFfUz1JmI3caN3FBeh2ZS1uvgtuMvpVH5xWH6sKei',  :oauth_token => 'lSBa4vn4whF8rsTFtTCGGg3xzmBxEbpqTfKBEuA4gjwiGy9MK1',  :oauth_token_secret => '2uy3wWmLackUbF7EYEAnAy0SBBUwyrbPwTK3dHCfcC4kBBmRAq' }) # Make the request puts client.info
When a line is preceded by the # symbol, the line is a comment, meaning that code is not executed. You can use this to write yourself little notes.
I had to make hidden file extensions visible in order to see that .txt had been added to the gem file, then move the file, and then it…. Almost worked.
Tumblr media
Now I’ve allowed full permissions to the gem file so I’ll try again.
Same problem. What?
Extensive research shows lots of people talking about chmod and chown, which are *nix terms. The windows equivalent would be takeown, but it doesn’t seem to do anything.
Tumblr media
I considered Ruby on Rails, but it looks too difficult. “Rails is a web application framework running on the Ruby programming language. If you have no prior experience with Ruby, you will find a very steep learning curve diving straight into Rails.” http://guides.rubyonrails.org/getting_started.html
I downloaded a tumblr Ruby client from elsewhere (https://rubygems.org/gems/tumblr_client/versions/0.8.5) and it seemed to install. Then suddenly require ceased to be recognised as a valid command and I can’t find anything online that will help with that.
Tumblr media
0 notes