是否可以使用javascript发送电子邮件?
我刚刚开始使用java和libgdx并拥有此代码,非常简单,它将一个精灵打印到屏幕上.这很完美,我从中学到了很多东西.
package com.MarioGame;
import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.InputProcessor;
public class Game implements ApplicationListener {
private SpriteBatch batch;
private Texture marioTexture;
private Sprite mario;
private int marioX;
private int marioY;
@Override
public void create() {
batch = new SpriteBatch();
FileHandle marioFileHandle = Gdx.files.internal("mario.png");
marioTexture = new Texture(marioFileHandle);
mario = new Sprite(marioTexture, 0, 158, 32, 64);
marioX = 0;
marioY = 0;
}
@Override
public void render() {
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT); …Run Code Online (Sandbox Code Playgroud) 我想找一个月的第一天(比如2010年9月1日和0:00)和一个月的最后一天(比如9月31日23:59)的时间戳.
我有一个指向CSS文件的字符串
../../css/style.css
Run Code Online (Sandbox Code Playgroud)
我想知道有多少
../
Run Code Online (Sandbox Code Playgroud)
在字符串内.
我如何使用JavaScript获得此功能?
有没有办法使用相机,但只能暂时保存图像?我正在使用以下代码加载相机,然后我使用onActivityResult()来获取图像(如果有的话......)
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
Run Code Online (Sandbox Code Playgroud)
问题是,当拍摄图像时,它会被保存到SD卡中.
编辑
意图由以下代码调用
String imagePath;
imagePath = Environment.getExternalStorageState() + "/images/myimage.jpg";
File file = new File( imagePath );
Uri outputFileUri = Uri.fromFile( file );
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
cameraIntent.putExtra( MediaStore.EXTRA_OUTPUT, outputFileUri );
startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST);
Run Code Online (Sandbox Code Playgroud)
当活动返回onActivityResult我正在使用的数据()时
File imageFile = new File(imagePath);
imageFile.delete();
Run Code Online (Sandbox Code Playgroud)
如何永远不会删除图像.此外,如果我进入我的画廊应用程序,图像是在一个默认名称(如image57465.jpg),我觉得它cameraIntent.putExtra( MediaStore.EXTRA_OUTPUT, outputFileUri );实际上没有工作.
编辑2
实际上,文件正在保存到SDCARD,并正确删除.但是,似乎正在保存缩略图.我想知道如何获取缩略图路径,以便我可以在使用它后删除它吗?
我在访问模板中的第一个相关对象时遇到了困难.
我正在使用
{{ course.student_set.all[0].get() }}
Run Code Online (Sandbox Code Playgroud)
但它抛出了大量的错误.我如何获得第一个相关对象?
干草,我有这样的标记
<div id="some-id">
<h2><a href="#">Title</a></h2>
</div>
Run Code Online (Sandbox Code Playgroud)
和一些像这样的jQuery
$(this).parent().parent().attr("id")
Run Code Online (Sandbox Code Playgroud)
$(this)指的是'h2'中的'a'标签
是否有一种更简单的方法来选择父div而不使用parent()两次.我试过了
$(this).parent("div").attr("id")
Run Code Online (Sandbox Code Playgroud)
但它不起作用.
谢谢
我希望使用纬度和长值找到2个位置之间的距离(以英里为单位),并检查它们是否在彼此相差10英里的范围内.
当用户登录时,他们的lat/long值将保存在会话中
$_SESSION['lat']
$_SESSION['long']
Run Code Online (Sandbox Code Playgroud)
我有2个功能
这个以英里为单位计算距离并返回舍入值
function distance($lat1, $lng1, $lat2, $lng2){
$pi80 = M_PI / 180;
$lat1 *= $pi80;
$lng1 *= $pi80;
$lat2 *= $pi80;
$lng2 *= $pi80;
$r = 6372.797; // mean radius of Earth in km
$dlat = $lat2 - $lat1;
$dlng = $lng2 - $lng1;
$a = sin($dlat / 2) * sin($dlat / 2) + cos($lat1) * cos($lat2) * sin($dlng / 2) * sin($dlng / 2);
$c = 2 * atan2(sqrt($a), sqrt(1 - $a));
$km = $r …Run Code Online (Sandbox Code Playgroud) 我有关于人际关系的问题.
我希望用户有友谊.因此,用户可以是另一个用户的朋友.我假设我需要通过友谊表使用ManyToManyField.但我无法让它发挥作用.有任何想法吗?
这是我的模特.
class User(models.Model):
username = models.CharField(max_length=999)
password = models.CharField(max_length=999)
created_on = models.DateField(auto_now = False, auto_now_add = True)
updated_on = models.DateField(auto_now = True, auto_now_add = False)
friends = models.ManyToManyField('self')
pendingFriends = models.ManyToManyField('self', through='PendingFriendship', symmetrical=False, related_name='friend_requested')
class PendingFriendship(models.Model):
user = models.ForeignKey('User', related_name='user')
requested_friend = models.ForeignKey('User', related_name='requested_friend')
created_on = models.DateField(auto_now = False, auto_now_add = True)
updated_on = models.DateField(auto_now = True, auto_now_add = False)
Run Code Online (Sandbox Code Playgroud)
谢谢
Hay我需要将投票系统实施到模型中.
我从Mike DeSimone那里得到了一个巨大的帮助,使得这项工作成为首要任务,但我需要扩展他的工作.
这是我目前的代码
视图
def show_game(request):
game = Game.objects.get(pk=1)
discussions = game.gamediscussion_set.filter(reply_to=None)
d = {
'game':game,
'discussions':discussions
}
return render_to_response('show_game', d)
Run Code Online (Sandbox Code Playgroud)
模板
<ul>
{% for discussion in discussions %}
{{ discussion.html }}
{% endfor %}
</ul>
Run Code Online (Sandbox Code Playgroud)
模型
class GameDiscussion(models.Model):
game = models.ForeignKey(Game)
message = models.TextField()
reply_to = models.ForeignKey('self', related_name='replies', null=True, blank=True)
created_on = models.DateTimeField(blank=True, auto_now_add=True)
userUpVotes = models.ManyToManyField(User, blank=True, related_name='threadUpVotes')
userDownVotes = models.ManyToManyField(User, blank=True, related_name='threadDownVotes')
def html(self):
DiscussionTemplate = loader.get_template("inclusions/discussionTemplate")
return DiscussionTemplate.render(Context({
'discussion': self,
'replies': [reply.html() for reply in …Run Code Online (Sandbox Code Playgroud)