Skip to content

Instantly share code, notes, and snippets.

package helloworld;
import javax.swing.JColorChooser;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.colorchooser.AbstractColorChooserPanel;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.geom.Rectangle2D;
#a remote call calls this method of the controller.
def purposes
@purpose = Purpose.new(params[:purpose])
@purpose.fidelity_report_id = params[:fidelity_report_id]
@purpose.user_id = @user.id
@purpose.save
respond_to do |format|
format.js {}
end
#This generates the form
<% @fidelity_report.send_froms.where(:attached=>true).each do |send_from| %>
<% if send_from.id==nil; next; end #don't generate a record for the new one%>
<%= form_for(send_from, :url=>fidelity_report_report_entities_send_froms_path(@fidelity_report,@send_from), :remote=>true) do |f| %>
to: <%= send_from.content %> <%= f.check_box :attached, :onchange => "detachEntity(this)"%> <%= f.label :attached %>
<%=f.hidden_field :id %>
<% end %>
<% end %>
#This is the generated section of html
When I request the base file in my app I get the following output to the console.
Rendered home/index.html.erb within layouts/application (1.5ms)
Completed 500 Internal Server Error in 1091ms (ActiveRecord: 0.0ms)
2: <html>
3: <head>
4: <title>Fidelity</title>
5: <%= stylesheet_link_tag "application", :media => "all" %>
6: <%= javascript_include_tag "application" %>
package helloworld;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.WindowConstants;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel;
@odinsbane
odinsbane / springs.kernel
Created May 2, 2017 12:27
threading problems.
__kernel void calculateForces( __global float* positions, __global int* connections, __global float* forces){
int i = get_global_id(0);
if(i<999){
int a = connections[2*i];
int b = connections[2*i + 1];
float delta = positions[b] - positions[a];
forces[a] += delta;
forces[b] -= delta;
}
@odinsbane
odinsbane / springs.c
Created May 2, 2017 15:46
chain springs with a force actin in the center.
#include <stdio.h>
#include <math.h>
#ifdef __APPLE__
#include <OpenCL/cl.h>
#else
#include <CL/cl.h>
#endif
const int N = 1000; //number of points.
const float dx = 1.0/(N-1);
boolean missing = false;
for(B b: collectionB){
boolean found = false;
for(A a: collectionA){
if(b.getField().equals(a.getField())){
found=true;
break;
}
}
if(!found){
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import java.util.ArrayList;
import java.util.List;
/**
* Created on 11.05.17.
*/
public class OthmEditor {
List<String> lines = new ArrayList<>();
import javax.swing.*;
import java.awt.*;
public class OptionOptions{
public static void main(String[] args){
while(true){
String[] options = {"OK", "NOT OK"};
String message = "What";
int n = JOptionPane.showOptionDialog(null, message, "Nytt smycke", JOptionPane.OK_CANCEL_OPTION,