« first day (544 days earlier)      last day (3244 days later) » 

user652649
2:52 AM
morning
 
mia
hey is anyoneh ere
 
user652649
probably
 
mia
does anyone know how to play video from swf? any player suggestion?
 
user652649
flowplayer?
 
Adobe Shockwave Player ?
 
mia
2:59 AM
trying flow
do you guys know how to create a plugin for videos
 
user652649
a wat
 
mia
nvm
wht ru up2
good night have a good one
 
3:17 AM
yeee installed gitlab and it working fine now
 
 
4 hours later…
user652649
7:20 AM
morning (2)
 
9:08 AM
morning
 
sup
 
soup
!!s/u/oo/g
 
@CSᵠ @erikroyall well they caniouse.com/#search=webworker , githoub.com/loudei/webview-plous (source)
@CSᵠ @erikroyall well they canioose.com/#search=webworker , githoob.com/loodei/webview-ploos (source)
 
user652649
morning
 
9:24 AM
@WesleyCrushed robocraft ?
 
user652649
@obiNullPoiиteяkenobi later maybe
 
user652649
i'm working a bit
 
user652649
this week i did nothing basically
 
robocraft in linux?
possibl?
 
user652649
@CSᵠ yes
 
9:26 AM
i wanna
where?
 
user652649
afaik it also works decently
 
i'ma gonna kick yo` assez
 
user652649
robocraftgame.com or via steam
 
@WesleyCrushed no problem :)
 
user652649
9:57 AM
@SecondRikudo your avatar is the scariest by far
 
10:57 AM
c="//ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac=‌​"//ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac="//‌​ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac=‌​"//ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac="//‌​ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac=‌​"//ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac="//
c="//ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac‌​="//ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac="/‌​/ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac‌​="//ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac="/‌​/ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac‌​="//ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac="//ac="//
^ does that make your eyes bleed bad?
 
user652649
thehellisdat
 
code digital camo
 
user652649
uh?
 
posted on October 26, 2014

New Cyanide and Happiness Comic.

 
@WesleyCrushed I know >:)
 
user652649
11:08 AM
:D
 
@WesleyCrushed report in
 
user652649
sup
 
afternoon bro
I wanted to know
say if we have an ajax script
and I want to execute another part on the same page
how do we do that
 
@Mr.Alien What do you mean "execute another part"?
 
user652649
^
 
11:19 AM
say I have a form
on index.php
on submit, I have a script with a url pointing to another page with processing php code for that form
but I dont want to have another page just to process my form
 
@Mr.Alien Yes, you do.
What you don't want is to mix presentation and logic on the same page.
 
I want to have processing php script on the same page I have my form on
so is that possi or it isn't
 
It's possible, but no, you don't want that.
 
user652649
it is possible but it's not a good idea
 
I know, I've provided ajax answers
but I have never tried placing processing script on the same page
so I wanted to try once
I tried taking out the url param from jquery
 
11:21 AM
@Mr.Alien It's simple really, you check that the REQUEST_METHOD is POST, or that $_POST['nameOfSubmitButton'] is present
 
so that it targets the page itself but doesn't work for me
wait let me try
 
user652649
you are probably talking of calling the form processing from within the template
 
user652649
that is wrong
 
user652649
but having a form on "self" is not bad
 
user652649
i do that all the time
 
11:22 AM
see, for example
we have form on index.php and if we use pure php
we have if(isset($_POST['whatever'])) {execute this}
so currently I have ^^ on process.php
so on submit jquery url points to process.php
 
user652649
yes you can do that
 
but I want the processing code on index.php itself
 
user652649
you use the same url for both displaying and processing
 
I do stop the intrusion of users if the form doesn't have ajax req by using if (isset(active_x shit))
@WesleyCrushed let me try
 
@Mr.Alien don't do that either.
ActiveX is IE7-, you don't need that.
Just build a form like you always would, and then use this:
2
A: Simple ajax form using javascript no jQuery

Second RikudoThe following is a far more elegant solution of the other answer, more fit for modern browsers. My reasoning is that if you need support for older browser you already most likely use a library like jQuery, and thus making this question pointless. /** * Takes a form node and sends it over AJAX....

To send it with AJAX.
Note that it's not perfect (I need to improve it to not include disabled elements)
 
11:25 AM
I use if (isset($_SERVER['HTTP_X_REQUESTED_WITH'])
and this is the way I do
11
A: jQuery Ajax POST example with PHP

Mr. AlienI would like to share a detailed way of how to post with PHP + Ajax along with errors thrown back on failure. First of all, create 2 files i.e form.php and process.php We will first create a form which will be then submitted using jQuery .ajax() method, rest will be explained in the comments. ...

 
user652649
you should use the http header Accept: ($_SERVER['HTTP_ACCEPT'])
 
^^ I always have one consistent way to go for
 
user652649
actually, i don't know what's the best way
 
user652649
i always used Accept:
 
ajax is too wide, I mean, so many ways to achieve one single thing
so the answer I posted is the way I usually go
where I've tons of form processing scripts on a single page
and it returns an json object with errros if any or a success message
but today I wanted to try on the same page
but doesnt work for me
 
11:29 AM
I go with the Accept header.
 
how do we use that
 
This way, I'm not tying myself to any specific AJAX implementation, and I can test my form with Postman or a similar app
3 mins ago, by Wesley Crushed
you should use the http header Accept: ($_SERVER['HTTP_ACCEPT'])
 
yea but how, if(server http accept) ?
also it will fetch anything right, get post whatever
 
@Mr.Alien $_SERVER['HTTP_ACCEPT'] will hold a string of the accept header as sent by the browser.
Do you know what an Accept header is?
 
these things are so complex, don't know why every language on the web is so handicap and requires some other language's help to achieve certain things
@SecondRikudo no
as I hardly use ajax
I prefer pure php submits
 
11:31 AM
@Mr.Alien The Accept header is an HTTP header sent by the client to the server, to specify what type of response the client is accepting.
 
user652649
i control the request like this: (pseudo code)
if(!isset($_POST))
      // display the form
else
     if($request->getAcceptType()->isPreferred("application/json"))
           // handle the form and send response as json data
     else
           // handle the form and send response as html data
 
Usually, the browser will accept text/html as well as a few others
You can see it in the network tab
 
@WesleyCrushed ok nice, so that if js is disabled, the else part will take care
@SecondRikudo ok, thanks, I'll check
also I don't use isset($_POST), I prefer using an index as well
 
user652649
@Mr.Alien yup
 
like $_POST['index']
 
user652649
11:33 AM
i don't often do that, but i sometimes do that, especially for msie7 support
 
user652649
like upload via ajax and similar things
 
uploading via ajax in pia
 
So I'm checking that
And respond according to that
 
we need hidden iframes and stuff
 
If the client accepts application/json, I respond with json
 
11:34 AM
@SecondRikudo ok let me try all that in few mins, till then am coding something else
 
If the client doesn't accept json and accepts text/xml, I'll respond with XML representation of the same object.
Depends on the application needs.
 
its a simple app am making
 
user652649
i always wanted to make a xhr polyfill for all browsers
 
user652649
i nearly did it but things became very hard to handle and i need to restart it
 
first complete your neon
you are just like me, I make 3 projects simultaneously and finish none
the only thing that benefits me is that I learn something new every time I do a new project
 
user652649
11:38 AM
well it's work. i can't skip them
 
user652649
the problem is completing them
 
12:06 PM
o/
@skibbi_bizzle pssst download clash of clans
that is all, now off to civ
 
why I cannot access a private property in public function
 
user652649
you can access private own properties, not private of other classes
 
wait
I have a connection class
sorry, engine class
and in that I have a private connection property
and public methods
I am trying to access that private method from other public class which am making to fetch the records from the db
 
user652649
code
 
but it says that am using private method
straight paste here?
 
user652649
12:12 PM
if it's private you can access it only from within the same class
 
sucks, so I need to make it public, cuz am making another class
can I extend the class?
 
user652649
if it's protected you can access it only from within the same class and derived classes (the ones that extend said class: class Derived extends SaidClass)
 
this oop is really pissing me off or am running too fast
<?php
	class Engine {
		private $connection;

    	/*
		 * Log Errors
		*/
		public function log_error($filename, $error) {
			file_put_contents($filename, file_get_contents($filename) . $error . "\r\n");
		}

		/*
		 * Database Connection
		*/
		public function plug() {
			try {
				$this->connection = new PDO('mysql:host=localhost;dbname='.Config::DB_NAME, Config::DB_USERNAME, Config::DB_PASSWORD);
				$this->connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
				$this->connection->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
My Engine class
class FetchInfoSingle {

	public function showdata($tbl_name, $col_name, $id_col = null, $id = null, $limit = null) {
		$engine = new Engine;
		$engine->plug();

		$query = "SELECT $col_name FROM $tbl_name";

		if($id_col != null && $id != null) $query .= " WHERE $id_col = $id";
		if($limit != null) $query .= " LIMIT $limit";

		return $engine->connection->query($query);
	}

}
and this is another class
to fetch single rows
and I know that last query part is wrong
I cannot return the object but ignore that
 
user652649
wait
 
user652649
stop
 
12:14 PM
HAMMERTIME!
 
user652649
hold on
 
user652649
:D
 
user652649
firstly, not for upsetting you
 
user652649
you didn't touch oop yet
 
user652649
so you aren't going too fast xD
 
12:15 PM
oh come on, its fine, insult :D
but you already answered huh, I cannot access private property from another class right?
 
user652649
so
 
so I need to make private $connection; as public
 
user652649
i give you some inputs
 
yes please
 
user652649
in random order
 
user652649
12:17 PM
the whole point of exceptions is that you wont have to if else everything
 
user652649
since upon error code gets caught by the first catch() available
 
on connection?
 
user652649
means that that try{} in plug() method more than likely should be elsewhere
 
so it will log my other errors as well?
 
user652649
you handle exceptions outside the classes
 
12:19 PM
or you are saying that whenever I exec a query I should use try and catch which I will do, was just testing to retrieve the row
 
user652649
it's not responsibility of the class to handle (which in your case is logging it) an error
 
this makes me think to go back to procedural, I would've completed this in a day or 2
@WesleyCrushed so I should log on calling and not inside the class?
 
user652649
you should use less try{} as possible
 
user652649
and by category
 
user652649
like:
 
12:20 PM
so when I make something like $engine = new Engine and then try $engine->plug() catch exception ?
why less try?
 
user652649
try
{
    Application::run()
}
catch(PerformanceException $perfException)
{
        $logger->warn($perfException)
}
catch(FatalException $emergencyException)
{
        $logger->emergency($emergencyException)
}
 
user652649
just pseudo code
 
user652649
you handle the error in one place only
 
user652649
not try catch everywhere
 
user652649
as i said the whole point of try catch is that upon error code execution jumps to the closest next catch()
 
12:22 PM
so a separate class for handling errors?
 
user652649
no
 
so is this application run a static thingy?
then you are using some other classes
 
user652649
you catch() execution errors inside the controllers
 
so are they inbuilt or you wrote them
 
user652649
@SecondRikudo help me :P
 
12:23 PM
for god sake, I need to leave doing oop
 
I was so good with procedural
 
user652649
@Mr.Alien stfu and concentrate
 
user652649
it's your attitude
 
What are you trying to do?
 
12:24 PM
not my attitude, am frustrated, or am not been much constantly coding with oop because all I do is procedural quickly and throw the project to the client
 
@Mr.Alien If that's the nature of your job, you don't really need OOP.
 
@SecondRikudo I have a private property in a class and am instantiating the connection class and accessing that private property in public method
 
user652649
wait @Mr.Alien did you get why you don't need to try catch everywhere?
 
OOP is good when you have code that needs modularity, code that uses different components that need to talk to one another (Router, Controllers, Views, etc)
 
12:26 PM
@WesleyCrushed not yet
 
@WesleyCrushed Code that uses try..catch is bad code.
 
@SecondRikudo in our country they don't give a fuck nor we haha
 
You shouldn't have Exceptions. At all.
 
I thought using try and catch are good
previously I used if and else
 
user652649
exactly
 
12:27 PM
@Mr.Alien You shouldn't rely on it.
 
user652649
exceptions are exceptions
 
Bad user input is not exception.
You expected it, it's not exceptional.
 
I was always using if and else for error logging but since I saw try and catch I thought they are cool
so should I stick to if and else?
 
@Mr.Alien A more elegant solution is to pass a Logger object
 
user652649
anyway @SecondRikudo i was trying to explain alien why this is not good:
 
12:28 PM
I don't know whats a logger object
 
user652649
public function plug() {
			try {
				$this->connection = new PDO('mysql:host=localhost;dbname='.Config::DB_NAME, Config::DB_USERNAME, Config::DB_PASSWORD);
				$this->connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
				$this->connection->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
			} catch(PDOException $error) {
				$this->log_error('error_log.txt', $error);
			}
		}
 
@Mr.Alien public function __construct(........., Logger $logger)
Then, $logger->log('line here')
Then, you can have multiple loggers, inheriting (or implementing) from the basic Logger class, and each implement the log method differently.
 
@WesleyCrushed what did you changed
 
@WesleyCrushed No.
 
user652649
@SecondRikudo that's alien's code
 
12:29 PM
The plug() method does not have the context to know what to do with the error.
 
user652649
y u no fuck ever read me @SecondRikudo
 
this will upset wes but am scrapping my oop classes and reverting to a single lib.php with functions
 
In some cases, I might terminate the entire application if I have an error connecting to the database.
 
lol
 
@WesleyCrushed :P
@Mr.Alien Listen
 
12:30 PM
but I will keep my oop files backed up
 
What is your application doing?
 
user652649
public function showdata($tbl_name, $col_name, $id_col = null, $id = null, $limit = null) {
$engine = new Engine; // this would connect to mysql every time
 
so I will also make the same with oop
 
What is the goal of the application?
 
user652649
public function showdata(Engine $passByReferenceTheEngine, $tbl_name, $col_name, $id_col = null, $id = null, $limit = null) {
 
12:30 PM
@SecondRikudo its a very small app, not at all oop req, I was doing oop to learn oop nothing else
 
@Mr.Alien That doesn't answer my question though.
 
@WesleyCrushed yea so I should always use one class for connection and losing connection
@SecondRikudo its a mailing app for my subscribers
say we have diwali, so I want to mail them all in an interval of say 5 mins
to wish them happy new year and stuff
 
@Mr.Alien Okay, what I think your problem is, is that you're still not doing OOP.
You are using classes and objects, but you aren't doing OOP.
 
yea I know as I JUST started
 
So, can you describe the application to me?
 
user652649
12:33 PM
@SecondRikudo he is convinced that he doesn't need oop. so he's trying to learn oop with this attitude. but the truth is (no offense) that also his procedural code sucks. i'm saying that because i sucked too with both procedural and oop and i'm still sucking on oop and many other fields. told you, just try to be less arrogant sometimes @Mr.Alien
 
Procedural has its uses, and OOP has its uses
You shouldn't force OOP paradigms on a procedural app and vice versa
 
user652649
@Mr.Alien one instance, not class
 
@SecondRikudo its not a huge app, a simple thing, store emails, store a template, make a queue, select mails, select template and start the queue to auto mail every one
 
@Mr.Alien The big idea of OOP is to hide things
 
@WesleyCrushed ok so master instance at the top
@WesleyCrushed am not at all arrogant :(
 
12:35 PM
If I have a class called RestClient can you guess what it does?
 
sorry if I ever sounded like one
@SecondRikudo nope
 
user652649
@SecondRikudo kill you? :D
 
@Mr.Alien Do you know what REST is?
 
yes
 
So what would a RestClient be?
 
user652649
12:36 PM
i don't know what rest is
 
user652649
Jul 13 at 11:25, by Wesabi
anyway guys remember the general rule: if Wes didn't hear of it, or if Wes heard of it but he doesn't use it, it surely sucks
 
@WesleyCrushed REST is a resource based API paradigm
 
@WesleyCrushed its a form of architecture
 
user652649
@SecondRikudo i know. i was kidding
 
It's the de-facto way of providing APIs over HTTP these days.
 
12:37 PM
@SecondRikudo better portability of the app?
 
My sarcasm detectors don't work on weekends.
@Mr.Alien No, a RestClient would be just that, a REST client
A client that is able to speak to a server which serves a REST API
 
user652649
i guess it's about having standard urls, right
 
user652649
so every app can use the same url pattern for all sites implementing a rest api
 
user652649
or something, right?
 
@WesleyCrushed The class? No, it's a standalone REST client
 
user652649
12:39 PM
no the class, rest in general
 
@WesleyCrushed Oh, REST is focused on resources, which you can manipulate (CRUD) using actions, (usually the HTTP verbs)
So /users/abc123 represents a single user resource
You can GET it, POST to create/change it, DELETE it, etc.
 
user652649
yea that's what i thought
 
user652649
why is important implementing it? i mean, which apps can use a rest api?
 
@WesleyCrushed The application I'm currently making in Node speaks to the eBay API, the PayPal API and the Amazon API
 
user652649
will take a look at it
 
12:42 PM
an API generally, and REST specficially is usually a form of abstraction over resource access. With a REST API, you don't know if the server uses a database, files, a few thousand Asian teenagers crunching numbers, or a pseudo random number generator
 
@SecondRikudo Shouldn't PUT change it in a REST interface?
 
@Mr.Alien let's take a simpler one
@PeeHaa Each one implements the semantics a bit differently
Let's say I have a class called Logger, can you guess what the point of that class would be?
 
So it is just a clusterfuck as any other interface :(
 
What part of the entire application will instances of Logger handle?
 
@SecondRikudo to log errors or any other info
 
12:44 PM
webservices suck. If only there was some standard :P
 
@Mr.Alien More generally, to log stuff
The entity that determines what to log is the entity that uses the Logger object.
The Logger class hides several things from the rest of the application.
It only exposes one public method: public function log(/* string */ $line) {
The rest of the application only ever sees that one method
OK so far @Mr.Alien?
 
not much, let me read for second time
ok got it, so that means its just like a mini framework, it can log anything, the method where we use to log matters, like I want to log error, or I want to log warning and so on?
 
user652649
@SecondRikudo i guess alien needs a lower level oop first
 
user652649
like what's visibility
 
Hey guys.. @SecondRikudo I enjoy your explanation, keep on! :)
 
user652649
12:48 PM
interfaces, classes
 
A different function somewhere in the application using your Logger object might look somewhat like this:
/* snip */
$this->doSomeAction();
$this->logger->log('Did this action'); //$this->logger somehow has an instance of Logger
/* snip */
 
hmmm
 
user652649
> The entity that determines what to log is the entity that uses the Logger object.
 
user652649
you log when you use a method, not when you implement a method
 
ok so I don't have to log things inside the class
only when I instantiate and use
 
user652649
12:50 PM
yes
 
hmmm
 
@Mr.Alien also, you might want to consider having a look at Dependency Injection later :)
 
function connectToDB($user, $pass, $logger) {
    $pdo = new PDO(.....);
    $logger->log('Connected to database successfully!');
}
Might make more sense this way ^
 
@HashemQolami way far, want to get the base first
@SecondRikudo yes :D
 
Notice how $logger only exposes log
 
12:51 PM
so in short, I don't have to use try and catch every time I query
 
It doesn't tell you anything about how that line is logged
 
ohh yea right
 
The connectToDB function trusts the logger to log succesfully
 
so you have code written in the method you just called
 
So now, that logic is abstracted and hidden away inside the Logger object
 
12:52 PM
for logging
k k got it
 
Now the nice thing is, the connectToDB function doesn't even know where the logs are.
The $logger might log to a file
It might also log to a database
It might not log at all
 
hmmm
 
user652649
or send an email
 
user652649
or to not log at all
 
user652649
logger is always a great way to explain oop :D
 
12:54 PM
As long as the logger has the log method that connectToDB expects it to have, all is good
 
or sends an sms
 
@Mr.Alien Yes
The best part is, the connectToDB function doesn't care which it is
It now no longer needs to worry itself with logging
 
ok, so once I change the logging part it affects everywhere so that I don't have to go in each class and modify
 
And can focus on what it does best, which is connecting to the database.
 
hmm
 
12:55 PM
@Mr.Alien Even better, you can have multiple versions of Logger, and pass any Logger instance you want based on conditions you set yourself
For example, in development, $logger->log might call echo to display the errors right away
And in production it might save to a file
 
user652649
@Mr.Alien remember the code that i wrote to you and that you dumped? ^ :D
 
yea just as we discussed, like mail, log in a text file, db or whatever
 
@WesleyCrushed the pastebin one with getters and setters?
 
For example, my application has so few exceptions, that I email them to myself.
 
12:56 PM
I didn't dump, referred but didnt understood cuz it was huge and complex
 
user652649
@Mr.Alien when i told you to have a Logger class instead of Engine->logger
 
In development environment, the Logger simply prints to stdout
 
@WesleyCrushed just before few mins I asked should I make a separate class for logging and you said no
 
user652649
@Mr.Alien are you fucking drunk mate xD
 
35 mins ago, by Mr. Alien
so a separate class for handling errors?
 
12:58 PM
@Mr.Alien Logging is an example, and it's relatively easy to explain because everyone knows what logging is
But that is the basis of OOP
 
I found analyzing PHP MVC-like frameworks inspiring; after learning the basics though...
 
user652649
and how handling errors is related to logging?
 
36 mins ago, by Wesley Crushed
no
 
Take the logic, hide it behind a public facing interface, and have other components use that interface.
 
I will again brush up the concepts first
 
12:59 PM
This allows you to change the underlying logic without touching the public facing interface, and thus not breaking anything else in your app
 
and then will try again to create a class
 

« first day (544 days earlier)      last day (3244 days later) »