我似乎无法使用twitter bootstrap框架获得div在其父级中的绝对位置.我有一系列遵循以下方案的行
<div id='wrapper'>
<div class='row-fluid'>
<div class='span2'>some content here</div>
<div class='span9'>other content to the side of the first div</div>
<div class='timestamp'>123456 this should align to the bottom right of wrapper</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS
.timestamp{
position:absolute;
bottom:0px;
right:0px;
}
Run Code Online (Sandbox Code Playgroud)
但是时间戳div总是将自己定位到整个dom文档的主体的绝对值,忽略任何中间div.是什么原因引起了这个?
我正在努力确保我使用sha512进行会话散列.当我打印出我的算法时,我得到了
Array
(
[0] => md2
[1] => md4
[2] => md5
[3] => sha1
[4] => sha224
[5] => sha256
[6] => sha384
[7] => sha512
[8] => ripemd128
etc....
)
Run Code Online (Sandbox Code Playgroud)
所以在php.ini中我设置它,
session.hash_function = 7
Run Code Online (Sandbox Code Playgroud)
我感到困惑的唯一原因是在.ini文件中它列出的散列方案与php打印的方式不同,例如0作为md5而不是md2.
; Select a hash function
; 0: MD5 (128 bits)
; 1: SHA-1 (160 bits)
Run Code Online (Sandbox Code Playgroud)
这只是旧版php版本的默认哈希方案吗?
我有一个用于向服务器发送请求的包装函数,如果服务器返回401的代码,我需要做一些特定的事情,我不知道如何获取这些数据
$.mobile.showPageLoadingMsg();
$.post(apiUrl+method,p,function(d) {
$.mobile.hidePageLoadingMsg();
console.log(d.success);
console.log(d.message);
if(d.success == true){
window[callback](d.data);
}
else{
if(d.message != null){
alert(d.message);
}
}
},'json')
.error(function() {
//need to check for 401 status here to do something
$.mobile.hidePageLoadingMsg();
alert("error");
});
Run Code Online (Sandbox Code Playgroud)
如果我的服务器端代码抛出一个401异常,jquery .error函数选择它只是因为它不是200 OK但我需要检查它是否是401代码.
我有一个字符串,其中包含哈希标记,我正在尝试将标记拉出来,我认为我非常接近,但得到的结果与多维数组相同
$string = "this is #a string with #some sweet #hash tags";
preg_match_all('/(?!\b)(#\w+\b)/',$string,$matches);
print_r($matches);
Run Code Online (Sandbox Code Playgroud)
产量
Array (
[0] => Array (
[0] => "#a"
[1] => "#some"
[2] => "#hash"
)
[1] => Array (
[0] => "#a"
[1] => "#some"
[2] => "#hash"
)
)
Run Code Online (Sandbox Code Playgroud)
我只想要一个数组,每个单词以一个哈希标记开头.
我正在尝试像在这个问题中一样 改变#hash标签链接页面加载 但是我认为因为我从jquery对象获取字符串data-caption属性有些东西不能正常工作.我有这样的DOM元素
<a class="thumbnail" rel="gallery" data-caption="#drink from somewhere #fun" data-pid="36" href="http://domain.com/something"><img src="http://domain.com/somephoto.png" alt="acee7bd0d8339b9ddcf4a259ec7ddeec"></a>
Run Code Online (Sandbox Code Playgroud)
它基本上是一个加载到模态的缩略图然后我试图抓住属性标题并从任何哈希标签创建链接
var caption = anchor.attr('data-caption') ? anchor.attr('data-caption') : null;
console.log(caption);
Run Code Online (Sandbox Code Playgroud)
其中变量锚是表示链接的jquery对象
我可以看到有一个标题,如果我检查它打印的日志"#drink from somewhere #fun"
所以现在把它扔进一个正则表达式替换fn
caption.replace(/#(\S*)/g,'<a href="http://twitter.com/#!/search/$1">$1</a>');
Run Code Online (Sandbox Code Playgroud)
然后将标题附加到DOM并激活链接.
但是字幕字符串没有任何反应我只是得到了我输入的相同的东西.
**编辑答案愚蠢的错误忘记将返回值分配给变量
var captionLinks = caption.replace(/#(\S*)/g,'<a href="http://twitter.com/#!/search/$1">$1</a>');
Run Code Online (Sandbox Code Playgroud) 我有一个客户端和服务器应用程序,一旦在客户端(android)上验证后,需要在SERVER端访问用户g +配置文件
我在这个客户端获得了一个ID令牌
@Background
void getAccessToken() {
String scopes = "audience:server:client_id:xxxxxxxxxxxxx.apps.googleusercontent.com";
Log.d(TAG,scopes);
try {
accessToken = GoogleAuthUtil.getToken(this,mPlusClient.getAccountName(),scopes);
Log.d(TAG,accessToken);
getPlusFriends();
}
catch (IOException transientEx) {
Log.e(TAG, transientEx.getMessage());
return;
}
catch (UserRecoverableAuthException e) {
Log.e(TAG, e.getMessage());
accessToken = null;
}
catch (GoogleAuthException authEx) {
Log.e(TAG, authEx.getMessage());
return;
}
catch (Exception e) {
throw new RuntimeException(e);
}
}
Run Code Online (Sandbox Code Playgroud)
这将给我一个长ID标记,如本博客中所述http://www.tbray.org/ongoing/When/201x/2013/04/04/ID-Tokens
我想我应该将该令牌发送到我需要做某事的服务器,将其转换为access_token.我可以验证id令牌吗?发送一个卷曲请求是好的
https://www.googleapis.com/oauth2/v1/tokeninfo?id_token=
它会像这样返回一个json字符串
{
"issuer": "accounts.google.com",
"issued_to": "xxxxxxxxxxxxxx.apps.googleusercontent.com",
"audience": "xxxxxxxxxxxxxx.apps.googleusercontent.com",
"user_id": "123456",
"expires_in": 3362,
"issued_at": 1382577073,
"email": "myemail@something",
"verified_email": true
}
Run Code Online (Sandbox Code Playgroud)
php服务器
\Config::load('google_api', …Run Code Online (Sandbox Code Playgroud) 我正在尝试在javascript中使用sqlite实现缓存.我有一个json对象,我正在尝试将其转换为字符串并输入到数据库中,但不断出现语法错误.
该表由两个字段组成,一个是md5字符串,另一个是json字符串,这是我如何定义db和table的
db = window.openDatabase("Database", "1.0", "Cordova Demo",10485760);
db.transaction(function(tx){
tx.executeSql('DROP TABLE IF EXISTS CACHE_DATA');
tx.executeSql('CREATE TABLE IF NOT EXISTS CACHE_DATA (md5 TEXT UNIQUE, data TEXT)');
},function(tx,error){
console.log('tx error: ' + error);
},function(){
console.log('tx success');
});
Run Code Online (Sandbox Code Playgroud)
这就是我试图输入变量d.data是json对象的数据.
var jsonString = JSON.stringify(d.data, null, '');
db.transaction(function(tx){
tx.executeSql('INSERT OR REPLACE INTO CACHE_DATA (md5, data) VALUES ("'+hash+'", "'+jsonString+'")');
},function(tx,error){
console.log(JSON.stringify(tx.message));
console.log(JSON.stringify(error));
},function(){
console.log('tx success');
});
console.log(jsonString);
Run Code Online (Sandbox Code Playgroud)
哪个会抛出错误
08-27 23:19:55.702: E/SQLiteLog(29831): (1) near "networks": syntax error
Run Code Online (Sandbox Code Playgroud)
我输入的实际字符串看起来像这样
08-27 23:19:55.652: D/CordovaLog(29831): {"networks":[{"id":"66","name":"Test"}],"expires":1346138396}
Run Code Online (Sandbox Code Playgroud)
我认为它与json字符串中的引号有关,但字段类型只是文本,所以我不确定语法错误是什么.
有任何想法吗?
我正在尝试将图像文件写入特定目录中的公共图库文件夹,但我一直收到一个错误,我无法打开该文件,因为它是一个目录.
到目前为止我所拥有的是以下内容
//set the file path
String path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES) + File.separator + directory;
File outputFile = new File(path,"testing.png");
outputFile.mkdirs();
FileOutputStream out = new FileOutputStream(outputFile);
bmp.compress(Bitmap.CompressFormat.PNG, 100, out);
Run Code Online (Sandbox Code Playgroud)
其中directory是应用程序名称.因此,应用程序保存的所有照片都将进入该文件夹/目录,但我一直收到错误
/storage/sdcard0/Pictures/appname/testing.png: open failed: EISDIR (Is a directory)
Run Code Online (Sandbox Code Playgroud)
即使我不尝试将它放在一个目录中并将变量路径转换为像文件一样
File path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
Run Code Online (Sandbox Code Playgroud)
我没有收到错误,但照片仍未显示在图库中.
***答案问题是,当我最初运行此代码时,它创建了一个名为testing.png的DIRECTORY,因为在创建目录中的文件之前我无法创建目录.因此,解决方案是首先创建目录,然后使用单独的文件写入目录
String path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).toString() + File.separator + directory;
//directory is a static string variable defined in the class
//make a file with the directory
File outputDir = new File(path);
//create dir if not there
if (!outputDir.exists()) { …Run Code Online (Sandbox Code Playgroud) 我正在尝试将尺寸通常为960x720的mp4视频转换为平方480:480视频,但它看起来通常看起来压扁,命令是
"-y -i %s -vf crop=480:480,transpose=%d -threads 5 -metadata:s:v rotate=0 -c:v libx264 -crf 27 -preset ultrafast -c:a copy -bsf:a aac_adtstoasc %s";
Run Code Online (Sandbox Code Playgroud)
我错过了什么,我需要首先缩小比例吗?
**编辑添加完整的控制台输出.ffmpeg命令已更新,但目标仍然保持不变,采取任意视频和方形裁剪
07-14 22:30:32.813: D/ffmpeg(30354): -y -i /data/data/com.myapp.app/cache:temp/i7h4ajm0nim1mbcnrqotvrhhsc.mp4 -vf scale=iw*sar:ih,transpose=1 -threads 5 -metadata:s:v rotate=0 -c:v libx264 -crf 27 -preset ultrafast -c:a copy -bsf:a aac_adtstoasc -aspect 1:1 /data/data/com.myapp.app/cache:temp/p1t3bhs0oa3lpqa67g5i9ninm9.ts
07-14 22:30:32.903: D/ffmpeg(30354): new time reamining 9283
07-14 22:30:32.913: D/FFmpeg(30354): Running publishing updates method
07-14 22:30:35.963: D/ffmpeg(30354): WARNING: linker: /data/data/com.myapp.app/files/ffmpeg has text relocations. This is wasting memory and prevents security hardening. Please …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 JWT 获得 spring 安全性以使用应用程序。我已经阅读了许多教程和示例,但没有一个真正适合我的用例。我们不通过用户名/密码授权,我们使用 twilio 来验证手机号码,然后我想创建一个简单的 JWT 令牌,以手机号码为主题。我已经能够做到这一点
这是 /api/v1/jwt 中存在的一个简单端点
@GetMapping("/jwt")
fun jwt(@RequestParam(value = "number", required = true) number: String): String? {
val jwtToken = Jwts.builder().setSubject(number).claim("roles", "user").setIssuedAt(Date()).signWith(SignatureAlgorithm.HS256, Base64.getEncoder().encodeToString("secret".toByteArray())).compact()
return jwtToken
}
Run Code Online (Sandbox Code Playgroud)
它返回一个有效的 JWT 令牌。
不过,我的安全配置不再起作用,现在所有端点似乎都受到保护,
@Configuration
@EnableWebSecurity
class SecurityConfig : WebSecurityConfigurerAdapter() {
@Bean
override fun authenticationManagerBean(): AuthenticationManager {
return super.authenticationManagerBean()
}
override fun configure(web: WebSecurity) {
web.ignoring().antMatchers("/v2/api-docs",
"/configuration/ui",
"/swagger-resources/**",
"/configuration/security",
"/swagger-ui.html",
"/webjars/**");
}
override fun configure(http: HttpSecurity) {
http.csrf()
.disable()
.sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.STATELESS)
.and()
.authorizeRequests()
.antMatchers("/api/v1/auth/**").permitAll()
.anyRequest().authenticated()
.and()
.addFilterBefore(JwtFilter(), …Run Code Online (Sandbox Code Playgroud) android ×3
hashtag ×2
javascript ×2
jquery ×2
php ×2
regex ×2
absolute ×1
cordova ×1
crop ×1
css ×1
css3 ×1
ffmpeg ×1
google-api ×1
google-oauth ×1
google-plus ×1
hash ×1
jquery-post ×1
json ×1
jwt ×1
positioning ×1
preg-match ×1
session ×1
spring ×1
spring-boot ×1
sqlite ×1
video ×1