We have JSON HTTP Post request that triggers from  one salesforce object to external system and we want to extend this functionality for other object. This code Fires and creates a Record in external system when the criteria matches. We want to have this functionality on other object in salesforce. I know we can Reuse the code and I don't want to end up creating another Class that does the same thing for different criteria. how do I store HTTP Request in separate class/method and Call out that whenever I need to Here is the code public class RadarUpdate { @future (callout=true) public static void postcallout(string Id) {  //querying patient relations record Patient_Satisfaction__c c = [select id,Name, Patient_First_Name__c,Patient_Last_Name__c, Reporter_Phone__c,Reporter_First_Name__c,Reporter_Last_Name__c, Reporter_Email__c, Description_of_Feedback__c from Patient_Satisfaction__c where Patient_Relation__c ='Referred to Privacy Office' order by lastmodifiedDate desc limit 1]; //generating JSON  JSONGenerator gen = JSON.createGenerator(true); gen.writeStartObject(); gen.writeObjectField('name', c.Patient_Last_Name__c + ', ' + c.Patient_First_Name__c); gen.writeObjectField('incident_group_id', 7448); gen.writeObjectField('description',c.Description_of_Feedback__c); gen.writeFieldName('submitted_by'); gen.writeStartObject(); gen.writeStringField('given_name',c.Reporter_First_Name__c); gen.writeStringField('surname', c.Reporter_Last_Name__c); gen.writeStringField('phone',c.Reporter_Phone__c); gen.writeStringField('email',c.Reporter_Email__c); gen.writeEndObject(); gen.writeFieldName('custom'); gen.writeStartObject(); gen.writeStringField('TRIPSS ID',c.Name); gen.writeEndObject(); String jsonS = gen.getAsString();  System.debug('jsonMaterials'+jsonS); //generating Http request Http http = new Http(); HttpRequest request = new HttpRequest(); request.setEndpoint('https://api.radarfirst.com/incidents'); request.setMethod('POST'); request.setHeader('Content-Type','application/json;charset=UTF-8'); request.setHeader('User-agent', 'Salesforce-integration-client'); request.setHeader('Authorization','Bearer eyJhbGciOiJSU0'); request.setBody(jsonS); // Set the body as a JSON object HttpResponse response = http.send(request); if (response.getStatusCode() != 201) { System.debug('The status code returned was not expected: ' +     response.getStatusCode() + ' ' + response.getStatus()); } else { System.debug(response.getBody()); } }  }
To consume REST services there is a lot of boilerplate code needed:   Build Apex Objects to model the responses Code to deserialize REST responses to those classes Handling of HTTP requests, responses and errors ...   Did anyone come up with patterns or best practices codified into an open source library or framework that one could just reuse in a similar project without reinventing the callout-wheel over an over again?  Like the zillions of trigger-frameworks that exist as repos on Github...
ArgumentNullException or NullReferenceException from extension method? What would you consider to be the best exception type to throw when an extension method is called on a null instance (where the extension method does not allow it)? Since extension methods are nothing but static methods you could argue that it should be ArgumentNullException, but on the other hand they're used like instance methods so it might be more natural to use the NullReferenceException. Let's take the following example:  public static string ToInvariantString(this IFormattable value, string format) {     return value.ToString(format, CultureInfo.InvariantCulture); }   This way a NullReferenceException will be thrown if the value parameter is null.   The other example would be:  public static string ToInvariantString(this IFormattable value, string format) {     if (value == null) throw new ArgumentNullException("value");     return value.ToString(format, CultureInfo.InvariantCulture); }   EDIT: In some of the answers you have pointed out that an extension methods can be called like a static method and in those cases a null reference exception would be wrong, which is a great point, and actually one of my concerns, not sure why I forgot to mention that in the question in the first place.   Someone also pointed out that it's wrong to throw a NullReferenceException, and yes, it is. That's why I don't throw it, I just let it happen (let the CLR throw it) by not guarding the method.  I think I favor the ArgumentNullException (that's what I've use so far) but I still think there is at least room to argue for an against the NullReferenceException since it seems more natural in most places where the method is going to be used. I want to count the total number of files in particular directory that ends with ".mp4" extension.  I am getting following command:  ls -F |grep -v / | wc -l   It count all the files in particular directory, but I want the count of files that end with .mp4 extension.  Is there any Ubuntu command for that? Cannot change brightness setting using function buttons or using the brightness control bar on HP laptop Is the empty set a group? How to inset a face? I am trying to set up a Minecraft rig mouth that will have more controls and will be rounded, but I am having issues trying to figure out what this guy did here. First, he did what looked like a loop cut and slide, but instead of drawing a line it selected all the edges it passed through. He then cut to a new clip where the mouth was already set up like this.    The video is in 3 times speed but if you download a youtube plugin you can slow it down to 0.25 speed of the video and then if you do the spacebar trick you can slow it down so it shows 1 frame at a time and it is really slow.  if you want or need to see the video.  All I am asking is how can I create those 8 basic segments. I'm quite new to neural networks and currently I'm trying to train a non convolutional neural network on the MNIST data set. I'm observing some behaviour I don't quite understand.   This is the code written with keras as the library:  # the data, split between train and test sets (x_train, y_train), (x_test, y_test) = fashion_mnist.load_data()  y_train = keras.utils.to_categorical(y_train, 10) y_test = keras.utils.to_categorical(y_test, 10) model = Sequential()  early_stopper = EarlyStopping(patience=3)  model.add(Flatten(input_shape=(28,28))) model.add(Dense(128, activation="relu")) model.add(Dense(128, activation="relu")) model.add(Dense(10, activation="softmax")) model.compile(loss="categorical_crossentropy", optimizer="adam", metrics=["accuracy"])  model.fit(x_train, y_train, epochs=20, validation_data=(x_test, y_test), callbacks=[early_stopper])   This gives me a validation_acc of around 20%. The funny thing is, when I change the activation functions to "sigmoid", the loss function to "mean_squared_error" and the optimizer to "sgd" my performance improves to around 85% after 50 epochs.   Having read  I wonder what's the reason for the bad performance of the network I presented in the code. ReLU, cross-entropy and a dynamic optimizer like Adam all seem to improve on the idea of a very vanilla neural network with stochastic gradient optimization, mean squared error as loss and sigmoid activation functions. Yet I get a really bad performance and if I increase the number of nodes in the hidden layers I often get a network that doesn't learn at all.   EDIT: I figured out it has something to do with me not normalizing the input to values between 0 and 1 ... but why is this the problem? I run windows 7. I run a Minecraft server, but I can only host around 9 players before lag appears.   I heard that Ubuntu can run a server with much better performance than Windows 7. I kind of like the whole idea of Ubuntu, but I don't want to change my OS to Unix or anything else.  Basically, my question is, does running a server (specifically and Minecraft server) run easier and faster on a Ubuntu server? On top of that, how would one set that up? Unexpected gaps in IDENTITY column I'm trying to install a service using InstallUtil.exe but invoked through Process.Start. Here's the code:  ProcessStartInfo startInfo = new ProcessStartInfo (m_strInstallUtil, strExePath); System.Diagnostics.Process.Start (startInfo);   where m_strInstallUtil is the fully qualified path and exe to "InstallUtil.exe" and strExePath is the fully qualified path/name to my service.  Running the command line syntax from an elevated command prompt works; running from my app (using the above code) does not. I assume I'm dealing with some process elevation issue, so how would I run my process in an elevated state? Do I need to look at ShellExecute for this?  This is all on Windows Vista. I am running the process in the VS2008 debugger elevated to admin privilege.  I also tried setting startInfo.Verb = "runas"; but it didn't seem to solve the problem. In  related question (), the OP asks if it is grammatical to use the definite article before phrases like Advanced programming in Java whitepaper and Microsoft Office 2010 product. The accepted answer by @Kosmonaut was:     Yes, it is. This is because the "Advanced programming in Java"   whitepaper phrase forms a syntactic unit, with whitepaper as the head   of the unit. The definite article for a phrase always corresponds to   the head of the phrase, so using the definite (or indefinite) article   for these phrases makes perfect sense and is correct English.   My question is whether the same answer applies to phrases like Heathrow Airport, Hyde Park,  Waterloo Station, Edgware Road and Parliament Square. I ask becase it seems to me that airport, park and station, etc. sound like they are part of the proper noun itself, and not simply a common noun. Moreover, I think the head of the unit in these cases would be the place name (first noun) and not the place type (second noun). If that's true, then I assume that no definite article should precede these phrases. Is that correct? If $x$ and $y$ are not both $0$ then $ x^2 +xy +y^2> 0$ Type safety: Unchecked cast In my spring application context file, I have something like:  &lt;util:map id="someMap" map-class="java.util.HashMap" key-type="java.lang.String" value-type="java.lang.String"&gt;     &lt;entry key="some_key" value="some value" /&gt;     &lt;entry key="some_key_2" value="some value" /&gt;    &lt;/util:map&gt;   In java class, the implementation looks like:  private Map&lt;String, String&gt; someMap = new HashMap&lt;String, String&gt;(); someMap = (HashMap&lt;String, String&gt;)getApplicationContext().getBean("someMap");   In Eclipse, I see a warning that says:  Type safety: Unchecked cast from Object to HashMap  What did I do wrong? How do I resolve the issue? Is there a higher register word that means to criticize something highly specific and inconsequential? Any synonym I can think of seems a little too vernacular, e.g. "to split hairs", "to nitpick". What's a more professional/academic way of saying this? I'd prefer a single word if one exists. fsck error on boot: /dev/sda6: UNEXPECTED INCONSISTENCY; RUN fsck MANUALLY Book Recommendation for mathematical finance Does anyone know a book which covers topics on:  Brownian Motion   Martingales   Stochastic Calculus  Stochastic Differential Equations   Options pricing. Black-Scholes model  Fundamental Theorems. Interest Rates   Random Walk   Applications in Insurance   Simulations. Convergence   Simulation methods   I would like something in-depth, but at an undergraduate level. Efficient way to check collision with potentially hundreds of objects I am trying to make a top down shooter that could potentially have hundreds of objects at once at one point. I need to check collision with projectiles, walls, and enemies. I am currently using ArrayLists which probably won't suffice later on and was wondering if someone had a good method or knows a good method for checking all of those objects at once. This is going to be a game for smartphones and is built in java. Any ideas would be great or if you could point me in some direction that would be fantastic.  Thanks in advance! Is Site Traffic Data Gone for Good After Fixing Previous Bug? There was a previous bug affecting site traffic statistics showing -zero- for months (). This has been fixed in that it is now graphing the data.  It appears that previous data may be lost? The graphs below are from . I don't have access to any other sites' graphs to see if they are showing similar results. How to concatenate text from multiple rows into a single text string in SQL server? How to get the list of properties of a class? Show that any bounded linear functional on a normed linear space is continuous Show that any bounded linear functional on a normed linear space is continuous.   Can we say that it is uniformly continuous ?   Also, is it true, if we reverse the statement    any continuous  linear functional on a normed linear space is bounded ??