420chan now has a web-based IRC client available, right here
Leave these fields empty (spam trap):
Name
You can leave this blank to post anonymously, or you can create a Tripcode by using the float Name#Password
A subject is required when posting a new thread
Subject
Comment
[*]Italic Text[/*]
[**]Bold Text[/**]
[~]Taimapedia Article[/~]
[%]Spoiler Text[/%]
>Highlight/Quote Text
[pre]Preformatted & Monospace text[/pre]
1. Numbered lists become ordered lists
* Bulleted lists become unordered lists
File

Sandwich


Community Updates

420chan now supports HTTPS! If you find any issues, you may report them in this thread
Going to College soon by Samuel Brenninghun - Fri, 20 Nov 2015 22:02:04 EST ID:CPpOXcN6 No.34839 Ignore Report Reply Quick Reply
File: 1448074924784.jpg -(112997B / 110.35KB, 1024x994) Thumbnail displayed, click image for full size. 112997
Need help deciding a major, I'm going to BMCC. I'm stuck between Computer Science, Computer Information Systems, Computer Network Technology. All sound really interesting too me but I have to choose one. I would like to learn how to code/program and learn everything there is to understand about networks/network security. But I've heard from many resources that computer science can be a waste of time, learning a bunch of unnecessary things and there are options to learn through boot camps or self-teaching that would be more efficient. I need wisdom and input. CIS seems to offer the most in variety. Im interesting in becoming a cyber security engineer, software systems developer or network architect or some thing along those lines. I guess I kind of want to learn all of the above but in the most efficient way and with a degree.
4 posts and 1 images omitted. Click Reply to view.
>>
Fanny Bisslebanks - Tue, 24 Nov 2015 16:56:12 EST ID:c9gFFBFz No.34844 Ignore Report Quick Reply
You will learn a lot of theory in a good CS program, which IMO is way more important than learning something specific that wont be useful 10 years from now. A CS degree + doing projects in your spare time is the best way to get into a good software company.

Employers will care more about your projects and what you know than your degree. Honestly the actual degree you get doesn't really matter at all, so long as you have one.
>>
Hamilton Pockfuck - Tue, 15 Dec 2015 09:08:39 EST ID:TBTemjoO No.34884 Ignore Report Quick Reply
>>34844
This guy is right. Do your own projects (they can be anything and you don't have to finish them), It's the best way to learn. Put those project openly on GitHub and you will have something actual to show when you're looking for a job.
>>
Martin Bingershaw - Sat, 02 Jan 2016 04:53:38 EST ID:XaSISda6 No.34955 Ignore Report Quick Reply
>>34884
>>
Albert Billingman - Mon, 04 Jan 2016 12:18:40 EST ID:WfPObyx2 No.34961 Ignore Report Quick Reply
>>34884
> you don't have to finish them
I disagree. Proof of concept is just the first milestone, the majority of the work and discipline and experience is in finishing a project. Seeing 1 project through to the last detail is IMO way more valuable and educational than 10 or 20 half-developed cool ideas.
>>
Hugh Hobblehire - Mon, 04 Jan 2016 14:03:20 EST ID:Ew1xe7Or No.34962 Ignore Report Quick Reply
>>34961

Definitely agree with finishing a project.

Maintenance phase can also count for a lot, depending on what the thing is.


combining conditional values by Angus Drondershit - Mon, 21 Dec 2015 23:41:22 EST ID:j1khxZ19 No.34909 Ignore Report Reply Quick Reply
File: 1450759282207.jpg -(56039B / 54.73KB, 840x480) Thumbnail displayed, click image for full size. 56039
After looking at the decompiled version of code I wrote, I noticed the compiler turning things like:
int x = 1 << 31;
into
int x = 1073741824;

Is it possible to merge things like this into one comparison?
if((x == 0x8) || (x == 0x4))
into
if(x == 0xC)

For speed.
9 posts omitted. Click Reply to view.
>>
Cedric Dabbleway - Wed, 23 Dec 2015 01:17:28 EST ID:FZqsCuoJ No.34921 Ignore Report Quick Reply
>>34920
I wrote the logical OR, bitwise OR, and switch statements in Java, then compiled and decompiled them.

The bitwise OR is 13 instructions.
The logical OR is 5 instructions.
The switch statement is 1 instruction.

The one instruction for the switch statement is called a lookupswitch, which is a log n operation.
>>
Betsy Clankinhet - Wed, 23 Dec 2015 17:27:42 EST ID:06pPpSX4 No.34928 Ignore Report Quick Reply
>>34921
Wait, for most C/C++ compilers switch-statements compile down into what're called jump-tables, which are O(1) operations, not O(log n) operations!
https://en.wikipedia.org/wiki/Branch_table
>>
Jarvis Siffingkedge - Wed, 23 Dec 2015 21:04:47 EST ID:FZqsCuoJ No.34931 Ignore Report Quick Reply
>>34928
Yeah, it looks like Java will determine if it will use a lookupswitch O(log n) or a tableswitch O(1) based on how "compact" your switch statement is.

I rewrote with switch code to include all number from 4 to 8, where only 4 or 8 would do something and Java used a tableswitch.
>>
Fuck Lightstock - Wed, 23 Dec 2015 21:30:48 EST ID:fsld9AGU No.34932 Ignore Report Quick Reply
>>34921

Number of instructions is almost meaningless nowadays, anyway. Performance on modern hardware is driven by memory access patterns.

As a disclaimer, once again, this is not something you should be micro-optimizing unless your profiler has told you that it's a problem. It is interesting in an academic sense, but if the switch statement in >>34920 showed up in production code, unless there was some justification for it I would fail the code review. I say this not to put a damper on the discussion, but in case any newbies are reading this and think this is a good idea to do everywhere.
>>
John Blackfoot - Sat, 26 Dec 2015 23:19:28 EST ID:06pPpSX4 No.34936 Ignore Report Quick Reply
>>34932
It's good to think about these things in the rare case that the code in question is the problem though! :)


android web app by Walter Worthinghall - Mon, 27 Jul 2015 13:43:37 EST ID:LrJ6NbnE No.34323 Ignore Report Reply Quick Reply
File: 1438019017755.png -(754802B / 737.11KB, 1595x680) Thumbnail displayed, click image for full size. 754802
Hi /prog/

I want to write an android app, which will show the headlines from various news webpages. You should be also able to access the article, by clicking the link.

What would be a good approach to do this?

I'm thinking of reading the html file, and just extracting certain tags like "headline", or just the plain text from an article, and show it on the screen.
This would be done for each webpage individually.

Is this retarded? Because I don't want to view all webpages on the screen, and I want a nice looking layout.
>>
Fucking Nongerlane - Mon, 27 Jul 2015 14:01:06 EST ID:aJsJBvJp No.34324 Ignore Report Quick Reply
>>34323
Most news sites offer a RSS, which will most likely give you exactly what you need.
>>
Walter Worthinghall - Mon, 27 Jul 2015 14:22:33 EST ID:LrJ6NbnE No.34325 Ignore Report Quick Reply
>>34324
alright thanks, well then there's no need for one.
>>
Nigger Crunnernock - Wed, 23 Dec 2015 18:13:24 EST ID:+6d1kOO+ No.34929 Ignore Report Quick Reply
>>34325
A webView Control is what you are looking to use.


c# streamreader hanging over irc by Ian Facklewill - Sun, 06 Dec 2015 14:42:00 EST ID:Ky+8GJE7 No.34857 Ignore Report Reply Quick Reply
File: 1449430920025.png -(142238B / 138.90KB, 650x376) Thumbnail displayed, click image for full size. 142238
I made a simple IRC client in Windows Forms, it can connect to a server, join channels and output text. I have a TextBox where I send the messages received from the server, which works, but the two problems I run into are it will only add one line at a time, or if I set it up with a timer, it will work until it hits the end and there are no messages being read. I have tried checking if it was null or length <=0 but it still hangs once it reaches the end.

I've looked into async and await, and tried that last night, but I seem to run into the same problems, either I can only get it to read one line at a time, or it will read and add them all then hang once it's at the end.

Why does it do this? How can I avoid it?
1 posts omitted. Click Reply to view.
>>
Betsy Diblingforth - Mon, 07 Dec 2015 02:47:11 EST ID:FZqsCuoJ No.34861 Ignore Report Quick Reply
>>34858
Can you do something like this?
string message;
while ((message = await _ircBot.ReadLineAsync()) != null)
{
txtServerMSG.Text += message + "\r\n";
}
>>
Jarvis Sugglehadge - Wed, 16 Dec 2015 13:26:44 EST ID:+6d1kOO+ No.34894 Ignore Report Quick Reply
>>34858
Look into using custom events.
>>
Isabella Cettingkurk - Fri, 18 Dec 2015 16:47:51 EST ID:p7RxQ6wv No.34904 Ignore Report Quick Reply
>>34857
Instead of constantly polling a method, you should have a look at System.Net.Sockets.TcpClient:

string server; //set to something
int port; //set to something
TcpClient client = new TcpClient;
client.Connect(server,port);
if(!client.Connected)
{
//connection failed
}

use client.GetStream() to load into a StreamReader or StreamWriter and you got your input /output..

some inspiration here (a commandline client):
Comment too long. Click here to view the full text.
>>
Nigger Crunnernock - Wed, 23 Dec 2015 12:44:24 EST ID:+6d1kOO+ No.34926 Ignore Report Quick Reply
You know stream reader/writer aren't more for file IO than reading or writing to/from a socket/TCP/IRC Chat connection look into events.
>>
Nigger Crunnernock - Wed, 23 Dec 2015 12:45:04 EST ID:+6d1kOO+ No.34927 Ignore Report Quick Reply
>>34926
Typo are not aren't*...


mysqhell by Phoebe Dipperwater - Tue, 15 Dec 2015 01:37:50 EST ID:Ky+8GJE7 No.34883 Ignore Report Reply Quick Reply
File: 1450161470121.png -(63119B / 61.64KB, 720x720) Thumbnail displayed, click image for full size. 63119
I'm trying to create a view where inside I want to display hours multiplied by a payrate. I'm not sure how I can get the payrate from a Job table which consists of an id, name, and payrate.

ProjectEmployee.Hours * Job.Rate as "Total"



A - id, name
B - id, name, rate
C - id, name
D - id, name
E - id, pid, eid, hours

I want to get the rate from B, multiply it by the hours in E, based on the id of A and C, where D is based on B and C.

My brain is fried, I've been working on this all day. Hopefully someone can point me in some sort of direction based on this vague information.
5 posts omitted. Click Reply to view.
>>
David Gandlecheck - Tue, 15 Dec 2015 13:45:41 EST ID:5q2tULje No.34890 Ignore Report Quick Reply
Why the fuck would you store all that in different tables? Smells like homework.
Anyway I won't even attempt solving this without giving the tables descriptive names, Brains aren't cpus dammit.
If you post that and a more verbose description of what you want to accomplish I will try to give it a shot.

Meanwhile install this app on your phone: http://www.sololearn.com/Course/SQL/
>>
Phoebe Dipperwater - Tue, 15 Dec 2015 17:39:56 EST ID:Ky+8GJE7 No.34892 Ignore Report Quick Reply
Well I managed to solve my problems, the "why the fuck is everything separated" helped as I tried to group them together a bit and found a solution, then realized I could still use my old tables if I added a couple more lines to the WHERE clause. MySQL has been much harder to wrap my head around than programming languages I feel like.
>>
Molly Grandfield - Tue, 15 Dec 2015 19:05:20 EST ID:elshgiNK No.34893 Ignore Report Quick Reply
1450224320360.jpg -(28809B / 28.13KB, 496x372) Thumbnail displayed, click image for full size.
> I find myself just wanting to use variables and conditionals with some sort of OOP approach
You mean you want to write imperative code. The fact that you want to use "OOP" in a database shows you know neither OOP nor data.

> just some sort of idea to complexly cascade down tables to get a simple equation.
Databases work on joins. Joins connect relations, like if you have associations x -> y and y -> z, then a join derives x -> y -> z. The query you needed was probably something like:

SELECT ProjectEmployee.Hours * Job.Rate as "Total"
FROM ProjectEmployee
JOIN Project ON ProjectEmployee.pid = Project.id
JOIN Job ON Project.jid = Job.id

> MySQL has been much harder to wrap my head around than programming languages I feel like.
Lucky for you you've attracted the attention of an RDBMS lesser god. Ask and I'll bestow on you more than you can handle, but beware, I don't preach the plebian consensus. The path to enlightenment is steep.
>>
Isabella Cettingkurk - Fri, 18 Dec 2015 15:54:45 EST ID:p7RxQ6wv No.34902 Ignore Report Quick Reply
>>34889
what the hell do you need it to be so complicated for?

Table A: Id(PK), Employee name, payrate, hours

if payrate is tiered:
Table A: Id(PK), Employee name, payrateId(FK to B.payrate), hours
Table B: Id(PK), payrate

if done by the book and payrate is tiered:
Table A: Id(PK), EmployeeId(FK to C.EmployeeName), payrateId(FK to B.payrate), hours
Table B: Id(PK), payrate
Table Id(PK), EmployeeName, (more infos...)

Only if a column has a set number of values with set information, you make a table for it.
Comment too long. Click here to view the full text.
>>
Isabella Cettingkurk - Fri, 18 Dec 2015 16:17:58 EST ID:p7RxQ6wv No.34903 Ignore Report Quick Reply
>>34902
contd.
just a few notes on the values you put in:

  1. payrates are rarely tiered (outside of McDonald's and co.), and can change in different ways depending on the individual. On year 1, Anne and Bob earn $10 an hour. The next year, Anne and Bob go to their boss to renegotiate their contract. Anne might end up with $12.50 an hour, while Bob (as a better negotiator) might get $14.75 an hour.
You payrate table will quickly inflate, especially with 100s or 1000s of employees

2. doing some extra work ahead of time (especially elementary stuff, like adding proper currency support) might save you time in the long run. Even though everybody gets paid in US Dollars today, the company might expand and expect you to pay out in Yen or Zimbabwe Dollars the next.
You can just sit back and relax when that happens and as an added bonus, use the same layout in future designs of your own creation.

3. For Table C, more infos on the employees can include telephone number, bank account number (possibly encrypted) and home address, that way it's fully fledged as a basic employee handling and payroll system...

...for that, add a table D for added bonus:
-Id (PK)
-Date
Comment too long. Click here to view the full text.


web security by Sidney Hirrykitch - Sun, 01 Mar 2015 02:12:36 EST ID:n3U2PjA0 No.33489 Ignore Report Reply Quick Reply
File: 1425193956356.jpg -(343721B / 335.67KB, 700x2622) Thumbnail displayed, click image for full size. 343721
what would i have to study/get a degree for
to do something with web security or a related field?
23 posts and 3 images omitted. Click Reply to view.
>>
Nell Sessledurk - Fri, 02 Oct 2015 06:35:51 EST ID:+6d1kOO+ No.34673 Ignore Report Quick Reply
>>34667

var _sf_async_config = {
uid:21329,...
domain: window.location.host.indexOf("www.audiotool.com") != -1 ? "audiotool.com" : "stage.audiotool.com"
};

(function(){
if (window.cbConfig) {
for (var k in cbConfig) {
_sf_async_config[k] = cbConfig[k]
}
}
function loadChartbeat() {
window._sf_endpt=(new Date()).getTime();
Comment too long. Click here to view the full text.
>>
Nell Sessledurk - Fri, 02 Oct 2015 07:04:06 EST ID:+6d1kOO+ No.34674 Ignore Report Quick Reply
>>34673
ahh some was hidden via css:

var _sf_async_config = {
uid:21329,
domain: window.location.host.indexOf("www.audiotool.com") != -1 ? "audiotool.com" : "stage.audiotool.com"
};

(function(){
if (window.cbConfig) {
for (var k in cbConfig) {
_sf_async_config[k] = cbConfig[k]
}
}
function loadChartbeat() {
Comment too long. Click here to view the full text.
>>
Ian Dirrybanks - Sat, 03 Oct 2015 13:12:26 EST ID:HL+K9IFi No.34678 Ignore Report Quick Reply
1443892346298.png -(46679B / 45.58KB, 178x154) Thumbnail displayed, click image for full size.
>>34669
thanks m8
>>34674
wtf is this shit
>>
Polly Haffingstone - Sat, 03 Oct 2015 20:02:53 EST ID:e5TJzaDU No.34681 Ignore Report Quick Reply
All the success stories I've heard have been about a child prodigy hacking into some big company's website and then getting hired by them because of it.
Try that
>>
Doris Nabbleham - Wed, 16 Dec 2015 17:06:29 EST ID:W5ZOPCjr No.34895 Ignore Report Quick Reply
1450303589897.jpg -(166376B / 162.48KB, 1024x768) Thumbnail displayed, click image for full size.
>>34665
same anon bumping again. I did like 5 microcorruptions it was cool then I got to something on encryption and got distracted learning c++. Back again reading a book on cryptography and will give this microcorruption hax0ring another shot.


Whaaaaaathefuck by David Depperville - Mon, 14 Dec 2015 17:49:06 EST ID:hwpLZnvL No.34877 Ignore Report Reply Quick Reply
File: 7.jpg -(80085B / 78.21KB, 666x69) Thumbnail displayed, click image for full size. 80085
Hello /prog/

I just assembled my first 3d printer kit. It's a Folgertech Kossel 2020 Delta style printer. Got everything together, all the wiring correct and connected it to my laptop. I downloaded Arduino, Repetier and Marlin firmware. G code is a pain so far. I successfully set the Z min, so it passes the paper test at G X0 Y0 Z0. Now the instructions for how to calibrate min. x and y position are a little shoddy. My main problem (as far as I can tell) is that Repetier can't process negative values, so I can seemingly only effectively use 1/4 of my print bed space. Entering G28 homes my printer, so the endstops are engaged. That much is fine, but G29, which is supposed to activate the Z probe (An inductive sensor), causes the hot end to move towards the z tower and begin climbing the towers, probing as it goes, so the z probe moves across the x/y axes as it should, but the z axis is engaged as well. The only reason I can come up with is that the command to tell the Z probe to comeback down to detect the metal print bed isn't there or something is wrong with it. If you've seen a video of z probing, the printhead comes down, senses the print bed, comes up, moves to the next spot and comes down to sense the print bed again, and so on.
I appreciate any guidance. I'm likely over complicating things, but I don't actually know.
>I'm waffling between this is super easy and this is super complex.
>>
David Depperville - Mon, 14 Dec 2015 17:51:26 EST ID:hwpLZnvL No.34878 Ignore Report Quick Reply
>>34877
FUCK!!
That was the wrong image. I didn't mean to upload that
>>
David Depperville - Mon, 14 Dec 2015 17:57:06 EST ID:hwpLZnvL No.34879 Ignore Report Quick Reply
>>34877
Please respect that this information is personal and that uploading it was a mistake. I do still appreciate advice about the calibration problem though.
>>
David Depperville - Mon, 14 Dec 2015 18:19:24 EST ID:hwpLZnvL No.34880 Ignore Report Quick Reply
>>34877
Thanks again to the moderators for fixing the image problem.
BACK to the matter at hand.
I am clearly a noob when it comes to programming.
>>
David Depperville - Mon, 14 Dec 2015 18:30:21 EST ID:hwpLZnvL No.34881 Ignore Report Quick Reply
>>34877
I'm thinking now that perhaps the 'no negative X and Y values' problem can be fixed the same way the Z max/min was fixed (by increasing the total Z max, allowing for more vertical build space) but I don't know how that would work with negative values. The non-negative value safeguard is handy for not driving the hot end into the print bed, but for x and y it's limiting.
>>
David Depperville - Mon, 14 Dec 2015 18:38:51 EST ID:hwpLZnvL No.34882 Ignore Report Quick Reply
>>34877
Honestly, you can ignore this thread now.
I've come across a good source of information which seems to have what I need.
Thanks for stopping by.
But mainly, stay classy.


Parse all image links from text by Graham Brannerlark - Wed, 14 Oct 2015 12:48:13 EST ID:TZ2ht1Xk No.34746 Ignore Report Reply Quick Reply
File: 1444841293594.jpg -(35170B / 34.35KB, 500x386) Thumbnail displayed, click image for full size. 35170
I have this large chunk of html code and I'd like to extract all the image urls out of it and have them seperated by line breaks. Can anyone help me? So far I've found this Regex expression, which finds them (not perfectly), but I I dont know how to extract them.
<img\s+[^>]*?src=("|')([^"']+)\1

Ideally I would have just the pure link http://xxx.jpg/r/nhttp://xxx.jpg, etc.

What should I do?
>>
Phoebe Fosslechine - Wed, 14 Oct 2015 13:12:47 EST ID:FZqsCuoJ No.34747 Ignore Report Quick Reply
>>34746
Could you just use javascript?
If so you can easily get all the image tags with document.getElementsByTagName('img')
You can then get the link by using .src on each element in the array
>>
Molly Murdworth - Wed, 14 Oct 2015 19:55:15 EST ID:ye2oh+to No.34748 Ignore Report Quick Reply
>>34746
Seems like the
\1
On the end is how you'd get the link text in some engines.You can use \1 when you use regex for the search/replace in hotepad++ for instance

I don't comment on how good it is at matching links I'm about to go to bed.
>>
Martin Siffingwell - Thu, 15 Oct 2015 15:47:19 EST ID:ye2oh+to No.34751 Ignore Report Quick Reply
Like >>34747 says, can you use javascript?
I don't know how to turn the console on in your browser if it doesn't appear when you press F12. paste this in the command line and all the image paths will be put in the console.

console.clear();
var imgs = document.getElementsByTagName( 'img' );
for( var i = 0, z = imgs.length; i < z; i++ )
{ console.log( imgs[ i ].src + '\n') }
>>
Phineas Bruzzlekare - Fri, 16 Oct 2015 00:02:44 EST ID:TZ2ht1Xk No.34752 Ignore Report Quick Reply
1444968164228.png -(80832B / 78.94KB, 247x248) Thumbnail displayed, click image for full size.
>>34751
Wow that's awesome! Thank you sir! I didn't even know you just run any javascript you wanted to like that. Sweet
>>
Fuck Bezzledetch - Sun, 13 Dec 2015 13:18:23 EST ID:S+TDDgvB No.34876 Ignore Report Quick Reply
>>34752
PROTIP: that's how interpreted languages work. They come with a built-in "try it before you buy it" button.


Cisco by Sophie Murdwill - Mon, 07 Dec 2015 08:13:20 EST ID:mssE6vKA No.34862 Ignore Report Reply Quick Reply
File: 1449494000724.png -(30704B / 29.98KB, 639x477) Thumbnail displayed, click image for full size. 30704
Hey guys, although this is networking and not programming, this was the closest board I could find to asking this question.

You can ignore the vty password because the question is asking about a physical connection; with the answer being the enable secret password, does that mean that enable secret always overrides the enable password?

Thanks.
>>
Sophie Murdwill - Mon, 07 Dec 2015 08:13:52 EST ID:mssE6vKA No.34863 Ignore Report Quick Reply
Literally just discovered /tech/, my bad. nb


Meteor help needed by Henry Deblingdadge - Wed, 02 Dec 2015 15:55:17 EST ID:rxlOp8Zj No.34854 Ignore Report Reply Quick Reply
File: 1449089717174.jpg -(392523B / 383.32KB, 1680x945) Thumbnail displayed, click image for full size. 392523
I've done a few meteor tutorials now and I'm still not confident on how to do what I'm asking.

How can Meteor be used to build a global leaderboard where the objects are the users connected to the server and their score is a self selected value. I'm having great difficulty in figuring how to create a page that shows everyone who logins in to it and then rank them.


greasey monkey by John Bibberlure - Sat, 28 Nov 2015 14:06:04 EST ID:Ky+8GJE7 No.34847 Ignore Report Reply Quick Reply
File: 1448737564053.jpg -(21766B / 21.26KB, 504x200) Thumbnail displayed, click image for full size. 21766
I tried to cobble together a greasemonkey script that opens a new tab whenever I click on an element of the class "title", but it doesn't seem to work. (This is for games following on Twitch, for some reason I can't ctrl click on games I'm following to open new tabs, so here's a convoluted solution):

// ==UserScript==
// @name Twitch Game Following Script
// @namespace TwitchGames
// @description Opens a new tab when you click on a game you follow.
// @include http://www.twitch.tv/directory/following/games
// @version 1
// @grant none
// ==/UserScript==

if(window.location.href.indexOf("directory/following/games" > 0){
var titles = document.getElementsByClassName("title");
for(var i = 0; i < titles.length; i++){
Comment too long. Click here to view the full text.
1 posts omitted. Click Reply to view.
>>
John Bibberlure - Sat, 28 Nov 2015 16:01:47 EST ID:Ky+8GJE7 No.34849 Ignore Report Quick Reply
>>34848

What do you mean syntax errors? Did you change anything to get it to work?
>>
Cyril Guvingfuck - Sat, 28 Nov 2015 22:12:03 EST ID:FZqsCuoJ No.34850 Ignore Report Quick Reply
>>34849
Your if statement (which I don't believe is necessary) is missing a parenthesis between your double quotation and your greater than sign

For the first line in your for statement, you are missing the square parenthesis to references the specific title

In your onclick function to get the text out of your title variable you should use title.innerHTML.trim() instead of title.text.trim()
>>
Cornelius Gossledock - Sat, 28 Nov 2015 22:46:48 EST ID:Ky+8GJE7 No.34851 Ignore Report Quick Reply
>>34850

Yeah, the if was a problem, though fixing that it still wouldn't work, nor with removing it. The square bracket was an i, so I guess even in the 'pre' formatted text it got interpreted as italic. Well doesn't work for me but it could be my browser setup or something, I don't know.

// ==UserScript==
// @name Twitch Game Following Script
// @namespace TwitchGames
// @description Opens a new tab when you click on a game you follow.
// @include http://www.twitch.tv/directory/following/games
// @version 1
// @grant none
// ==/UserScript==

var titles = document.getElementsByClassName("title");
Comment too long. Click here to view the full text.
>>
Cyril Guvingfuck - Sat, 28 Nov 2015 23:28:16 EST ID:FZqsCuoJ No.34852 Ignore Report Quick Reply
>>34851
Sorry, it looks like the problem is with the scope of your variables. You cannot access 'title' in your function, but you can use 'this'.
var titles = document.getElementsByClassName("title");
for(var ii = 0; ii < titles.length; ii++){
titles[ii].onclick = function() { window.open("http://www.twitch.tv/directory/game/" + this.innerHTML.trim()); };
}
>>
Fuck Figgleman - Sun, 29 Nov 2015 14:16:20 EST ID:nFrbERQF No.34853 Ignore Report Quick Reply
>>34852
title can be accessed in his function, but the problem is that the closure binds to the variable, not the value, so that when the function is evaluated the variable will contain the last value assigned to it, not the value it had at the time the function was assigned.

Using this works for event handlers or functions called with call/apply, more generally one can wrap the for block in a function call, passing the value of title as a parameter so that each onclick handler binds to a new local variable.


<<Last Pages
0 1 2 3 4 5 6 7 8 9 10 11
Report Post
Reason
Note
Please be descriptive with report notes,
this helps staff resolve issues quicker.